File: Main.hs

package info (click to toggle)
haskell-dimensional 1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 348 kB
  • sloc: haskell: 2,370; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{-# LANGUAGE NoImplicitPrelude #-}

module Main where

import Criterion.Main
import Numeric.Units.Dimensional.Prelude
import qualified Prelude as P

main :: IO ()
main = defaultMain [
         bench "RawArithmetic" $ nf rawArithmetic 1000
       , bench "Arithmetic" $ nf arithmetic 1000
       ]

rawArithmetic :: Int -> [Double]
rawArithmetic n = fmap (P./ 3.7) $ [1.0 .. fromIntegral n]

arithmetic :: Int -> [Density Double]
arithmetic n = fmap (/ (3.7 *~ cubic meter)) $ [1.0 .. fromIntegral n] *~~ kilo gram