[from now] 2014/04/14 08:20:05

[36mdiff --git a/daily_data/20140411.txt b/daily_data/20140411.txt[m
[36mindex 0423796..e86f347 100644[m
[36m--- a/daily_data/20140411.txt[m
[36m+++ b/daily_data/20140411.txt[m
[34m@@ -1 +1 @@[m
[1m-Nutrient {calorie = Just 1009.0, protein = Just 42.8, fat = Just 17.900002, carbon = Just 171.5}[m
[32m\ No newline at end of file[m
[4m+[m[4mNutrient {calorie = Just 1865.0, protein = Just 70.4, fat = Just 60.600002, carbon = Just 262.0}[m
[32m\ No newline at end of file[m
[36mdiff --git a/daily_data/20140412.txt b/daily_data/20140412.txt[m
[36mnew file mode 100644[m
[36mindex 0000000..ca282a0[m
[36m--- /dev/null[m
[36m+++ b/daily_data/20140412.txt[m
[34m@@ -0,0 +1,7 @@[m
[4m+[m[4mNutrient {calorie = Just 3451.2, protein = Nothing, fat = Nothing, carbon = Nothing}[m
[4m+[m[4mNutrient {calorie = Just 283.0, protein = Just 3.6, fat = Just 15.0, carbon = Just 33.4}[m
[4m+[m[4mNutrient {calorie = Just 239.0, protein = Just 5.1, fat = Just 13.4, carbon = Just 23.4}[m
[4m+[m[4mNutrient {calorie = Just 825.12, protein = Just 61.540203, fat = Just 59.8212, carbon = Just 0.3438}[m
[4m+[m[4mNutrient {calorie = Just 550.08, protein = Just 41.026802, fat = Just 39.8808, carbon = Just 0.2292}[m
[4m+[m[4mNutrient {calorie = Just 1328.0, protein = Nothing, fat = Nothing, carbon = Nothing}[m
[4m+[m[4mNutrient {calorie = Just 226.0, protein = Nothing, fat = Nothing, carbon = Nothing}[m
[36mdiff --git a/daily_data/20140413.txt b/daily_data/20140413.txt[m
[36mnew file mode 100644[m
[36mindex 0000000..d1f8556[m
[36m--- /dev/null[m
[36m+++ b/daily_data/20140413.txt[m
[34m@@ -0,0 +1,8 @@[m
[4m+[m[4mNutrient {calorie = Just 2524.137025, protein = Just 55.095, fat = Just 138.885, carbon = Just 267.385}[m
[4m+[m[4mNutrient {calorie = Just 176.13702499999997, protein = Just 5.125, fat = Just 3.0749999999999997, carbon = Just 27.674999999999997}[m
[4m+[m[4mNutrient {calorie = Just 77.0, protein = Just 8.61, fat = Just 7.21, carbon = Just 0.21}[m
[4m+[m[4mNutrient {calorie = Just 871.0, protein = Just 9.36, fat = Just 53.3, carbon = Just 88.39999999999999}[m
[4m+[m[4mNutrient {calorie = Just 268.0, protein = Just 4.3, fat = Just 17.3, carbon = Just 23.8}[m
[4m+[m[4mNutrient {calorie = Just 221.0, protein = Just 3.5, fat = Just 14.2, carbon = Just 19.9}[m
[4m+[m[4mNutrient {calorie = Just 369.0, protein = Just 4.1, fat = Just 22.3, carbon = Just 40.5}[m
[4m+[m[4mNutrient {calorie = Just 542.0, protein = Just 20.1, fat = Just 21.5, carbon = Just 66.9}[m
[36mdiff --git a/src/Data/BaseUnit.hs b/src/Data/BaseUnit.hs[m
[36mindex 975cc61..d2fd5c9 100644[m
[36m--- a/src/Data/BaseUnit.hs[m
[36m+++ b/src/Data/BaseUnit.hs[m
[34m@@ -1,2 +1,2 @@[m
[32m module Data.BaseUnit(BaseUnit) where[m
[1m-type BaseUnit = Maybe Float[m
[4m+[m[4mtype BaseUnit = Maybe Double[m
[36mdiff --git a/src/List/Meals.hs b/src/List/Meals.hs[m
[36mnew file mode 100644[m
[36mindex 0000000..806ca40[m
[36m--- /dev/null[m
[36m+++ b/src/List/Meals.hs[m
[34m@@ -0,0 +1,7 @@[m
[4m+[m[4mmodule List.Meals where[m
[4m+[m
[4m+[m[4mimport Meal[m
[4m+[m
[4m+[m[4moatsMeal_100 = defaultNutrient {calorie = Just (T.jouleToCalorie 719), protein = Just 5.0, fat = Just 3.0, carbon = Just 27} `nMal` (100 / 40)[m
[4m+[m
[4m+[m[4meggM = defaultNutrient {calorie = Just 77, protein = Just (12.3 * 0.7), fat = Just (10.3 * 0.7), carbon = Just (0.3 * 0.7)}[m
[36mdiff --git a/src/Main.hs b/src/Main.hs[m
[36mindex 181c5a8..83bf20d 100644[m
[36m--- a/src/Main.hs[m
[36m+++ b/src/Main.hs[m
[34m@@ -1,8 +1,10 @@[m
[32m module Main where[m
[32m [m
[1m-import Meal[m
[4m+[m[4mimport  Meal[m
[4m+[m[4m--import qualified List.Meal[m
[32m --import Workout[m
[1m-import Util.Util[m
[4m+[m[4mimport qualified Util.Util as U[m
[4m+[m[4mimport qualified Util.Translate as T[m
[32m --import Data.Time[m
[32m --import Data.Time.Lens[m
[32m [m
[34m@@ -11,12 +13,21 @@[m[32m [m[33mimport Util.Util[m
[32m main :: IO ()[m
[32m main = do[m
[32m     let windows = "C:/HOME/learning_haskell/calorie/daily_data"[m
[1m-    let mac = "$HOME/learning_haskell/calorie_hs/daily_data"[m
[1m-    let breakFirst = defaultNutrient {calorie = Just 337, protein = Just 7.5, fat = Just 5.4, carbon = Just 63.4}[m
[1m-    let lunch = defaultNutrient {calorie = Just 190, protein = Just 3.8, fat = Just 4.0, carbon = Just 36.6}[m
[1m-    let butadon = defaultNutrient {calorie = Just 373, protein = Just 11.2, fat = Just 6.8, carbon = Just 68.5}[m
[1m-    let beaf = defaultNutrient {calorie = Just 109, protein = Just 20.3, fat = Just 1.7, carbon = Just 3.0}[m
[1m-    let total = show $ foldl1 nAdd [breakFirst, lunch, butadon, beaf][m
[1m-    writeFile (windows ++ "/" ++ "20140411.txt") total[m
[4m+[m[4m    let mac = "/Users/theatrical/learning_haskell/calorie_hs/daily_data"[m
[4m+[m[4m    let oatsMeal_100 = defaultNutrient {calorie = Just (T.jouleToCalorie 719), protein = Just 5.0, fat = Just 3.0, carbon = Just 27} `nMal` (100 / 40)[m
[4m+[m[4m    let n_list =  [[m
[4m+[m[4m                  (oatsMeal_100 `nMal` 0.41)[m
[4m+[m[4m                  , defaultNutrient {calorie  =  Just 77,  protein  =  Just (12.3 * 0.7),  fat  =  Just (10.3 * 0.7),  carbon  =  Just (0.3 * 0.7)}[m
[4m+[m[4m                  , defaultNutrient {calorie  =  Just 67,  protein  =  Just 0.72,  fat  =  Just 4.1,  carbon  =  Just 6.8} `nMal` 13[m
[4m+[m[4m                  , defaultNutrient {calorie  =  Just 268,  protein  =  Just 4.3,  fat  =  Just 17.3, carbon  =  Just 23.8}[m
[4m+[m[4m                  , defaultNutrient {calorie  =  Just 221,  protein  =  Just 3.5,  fat  =  Just 14.2, carbon  =  Just 19.9}[m
[4m+[m[4m                  , defaultNutrient {calorie  =  Just 369,  protein  =  Just 4.1,  fat  =  Just 22.3, carbon  =  Just 40.5}[m
[4m+[m[4m                  , defaultNutrient {calorie  =  Just 542,  protein  =  Just 20.1,  fat  =  Just 21.5, carbon  =  Just 66.9}[m
[4m+[m[4m                  ][m
[4m+[m[4m    let total = show $ foldl1 nAdd n_list[m
[4m+[m[4m    writeFile (mac ++ "/" ++ "20140413.txt") $[m
[4m+[m[4m                                                total[m
[4m+[m[4m                                                ++ "\n"[m
[4m+[m[4m                                                ++ (foldl1 (++) . map  ( (++ "\n") . show) $ n_list)[m
[32m     putStrLn total[m
[1m-    putStrLn . show $ (applyBothSide (+) $ (*24) . length ) "1234567" "89"[m
[4m+[m[4m    putStrLn . show $ (U.applyBoth (+) $ (*24) . length ) "1234567" "89"[m
[36mdiff --git a/src/Meal.hs b/src/Meal.hs[m
[36mindex 86b8625..c46a2ef 100644[m
[36m--- a/src/Meal.hs[m
[36m+++ b/src/Meal.hs[m
[34m@@ -8,6 +8,7 @@[m[32m [m[33mmodule Meal ([m
[32m             , calorieCal[m
[32m             , nAdd[m
[32m             , nMal[m
[4m+[m[4m            , nDiv[m
[32m             , cMinus[m
[32m             ) where[m
[32m [m
[34m@@ -33,16 +34,19 @@[m[32m [m[33ma `nAdd` b = Nutrient{calorie  = cal, protein = p, fat = f, carbon = c}[m
[32m         f = fat a `nAdd'` fat b[m
[32m         c = carbon a `nAdd'` carbon b[m
[32m [m
[1m-nMal :: Nutrient -> Float -> Nutrient[m
[4m+[m[4mnMal :: Nutrient -> Double -> Nutrient[m
[32m n `nMal` a = Nutrient{calorie  = cal, protein = p, fat = f, carbon = c}[m
[32m     where[m
[1m-        nMal' :: BaseUnit -> Float -> BaseUnit[m
[4m+[m[4m        nMal' :: BaseUnit -> Double -> BaseUnit[m
[32m         n' `nMal'` a' = fmap (a' *) n'[m
[32m         cal = calorie n `nMal'` a[m
[32m         p = protein n `nMal'` a[m
[32m         f = fat n `nMal'` a[m
[32m         c = carbon n `nMal'` a[m
[32m [m
[4m+[m[4mnDiv :: Nutrient -> Double -> Nutrient[m
[4m+[m[4mn `nDiv` a = n `nMal` (1 / a)[m
[4m+[m
[32m cMinus :: Nutrient -> Calorie -> Calorie[m
[32m cMinus nu c = calorie nu `nMinus'` c[m
[32m     where[m
[34m@@ -51,15 +55,14 @@[m[32m [m[33mcMinus nu c = calorie nu `nMinus'` c[m
[32m [m
[32m data NurietKind = Protein | Carbon | Fat deriving Eq[m
[32m calorieCal :: NurietKind -> NutrientQuantity -> Calorie[m
[1m-calorieCal _ Nothing = Nothing[m
[1m-calorieCal Protein jn = fmap (4*) jn[m
[1m-calorieCal Carbon  jn = fmap (4*) jn[m
[1m-calorieCal Fat     jn = fmap (9*) jn[m
[4m+[m[4mcalorieCal Protein = fmap (4*)[m
[4m+[m[4mcalorieCal Carbon  = fmap (4*)[m
[4m+[m[4mcalorieCal Fat     = fmap (9*)[m
[32m [m
[32m defaultNutrient :: Nutrient[m
[32m defaultNutrient = Nutrient{calorie = Nothing, protein = Nothing, fat = Nothing, carbon = Nothing}[m
[32m [m
[1m-data Meal = Meal{name :: String, nutrient :: Maybe Nutrient, date :: String} deriving(Show, Eq, Read, Ord)[m
[4m+[m[4mdata Meal = Meal{name :: String, nutrient :: Nutrient, date :: String} deriving(Show, Eq, Read, Ord)[m
[32m defaultMeal :: Meal[m
[1m-defaultMeal = Meal{name = "",  nutrient = Nothing, date = ""}[m
[4m+[m[4mdefaultMeal = Meal{name = "",  nutrient = defaultNutrient, date = ""}[m
[32m [m
[36mdiff --git a/src/Util/Translate.hs b/src/Util/Translate.hs[m
[36mnew file mode 100644[m
[36mindex 0000000..bbe76d2[m
[36m--- /dev/null[m
[36m+++ b/src/Util/Translate.hs[m
[34m@@ -0,0 +1,10 @@[m
[4m+[m[4mmodule Util.Translate ([m
[4m+[m[4m                      calorieToJoule[m
[4m+[m[4m                      , jouleToCalorie[m
[4m+[m[4m                    ) where[m
[4m+[m[4mcalorieToJoule :: Fractional a => a -> a[m
[4m+[m[4mcalorieToJoule = (*) 4.1868[m
[4m+[m
[4m+[m[4mjouleToCalorie :: Fractional a => a -> a[m
[4m+[m[4mjouleToCalorie = (*) 0.239[m
[4m+[m
[36mdiff --git a/src/Util/Util.hs b/src/Util/Util.hs[m
[36mindex 0b7b839..d6e1d90 100644[m
[36m--- a/src/Util/Util.hs[m
[36m+++ b/src/Util/Util.hs[m
[34m@@ -1,6 +1,6 @@[m
[32m module Util.Util([m
[1m-                applyBothSide[m
[4m+[m[4m                applyBoth[m
[32m                 ) where[m
[32m [m
[1m-applyBothSide :: (t1 -> t1 -> t2) -> (t -> t1) -> t -> t -> t2[m
[1m-applyBothSide f g x y = g x `f` g y[m
[4m+[m[4mapplyBoth :: (t1 -> t1 -> t2) -> (t -> t1) -> t -> t -> t2[m
[4m+[m[4mapplyBoth f g x y = g x `f` g y[m