diff --git a/cout-recette.hs b/cout-recette.hs index 83dcf32..693ae7a 100755 --- a/cout-recette.hs +++ b/cout-recette.hs @@ -1,5 +1,6 @@ #! /usr/bin/env runhaskell +-- * Data types definition data Ingredient = Ingredient { ingredientName :: String , unit_cost :: Double }deriving (Show) @@ -12,6 +13,7 @@ data Recipe = Recipe { recipeName :: String , useNumber :: Double }deriving (Show) +-- * Calculations recipeCost :: Recipe -> Double recipeCost (Recipe _ bom _ _) = sum . map ingredientCost $ bom @@ -27,6 +29,7 @@ useCost (Recipe _ _ _ uses) totalCost = totalCost / uses (→) :: Ingredient -> Double -> UsedIngredient (→) ingredient qtt = UsedIngredient ingredient qtt +-- * Example (in french for now) eau = Ingredient "Eau" 0.003 savonMarseille = Ingredient "Savon de Marseille" 3.36 bicarbonate = Ingredient "Bicarbonate de soude" 3.81