aboutsummaryrefslogtreecommitdiff
path: root/src/Food.purs
blob: b1e3d29558d64ca3e2441799d4226607d6d05dab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Food
  ( Aliment
  , all
  , glycemicLoad
  ) where

import Data.Int (toNumber)
import Prelude

type Aliment =
  { name :: String
  , glycemicIndex :: Int
  , carbohydrates :: Int -- for 100 grams
  }

glycemicLoad :: Aliment -> Number
glycemicLoad aliment = toNumber aliment.glycemicIndex * toNumber aliment.carbohydrates / 100.0

all :: Array Aliment
all =
  [ { name: "oignon", glycemicIndex: 15, carbohydrates: 9 }
  , { name: "olive", glycemicIndex: 15, carbohydrates: 6 }
  , { name: "haricot rouge", glycemicIndex: 35, carbohydrates: 24 }
  , { name: "haricot blanc", glycemicIndex: 35, carbohydrates: 13 }
  ]