[from now] 2014/04/16 00:27:27

[36mdiff --git a/src/Main b/src/Main[m
[36mnew file mode 100755[m
[36mindex 0000000..fb6c6d6[m
Binary files /dev/null and b/src/Main differ
[36mdiff --git a/src/Main.hs b/src/Main.hs[m
[36mindex d4b6054..05ed578 100644[m
[36m--- a/src/Main.hs[m
[36m+++ b/src/Main.hs[m
[34m@@ -1,10 +1,12 @@[m
[32m module Main where[m
[32m [m
[32m import qualified Meal as M[m
[4m+[m[4mimport qualified Workout as W[m
[32m import qualified Util.Util as U[m
[32m import qualified Util.Translate as T[m
[32m import Data.Time[m
[32m import Control.Applicative[m
[4m+[m[4mimport System.Environment[m
[32m [m
[32m [m
[32m filename :: IO String[m
[34m@@ -27,10 +29,14 @@[m[32m [m[33mzeroFill len n = if l >= len[m
[32m [m
[32m main :: IO ()[m
[32m main = do[m
[4m+[m[4m    (cmd:_) <- getArgs[m
[32m     let windows = "C:/HOME/learning_haskell/calorie/daily_data"[m
[32m     let mac = "/Users/theatrical/learning_haskell/calorie_hs/daily_data"[m
[1m-    file <- pure (\x -> windows ++ "/" ++ x ++ ".txt") <*> filename[m
[1m-    meal <- M.insertMeal[m
[1m-    appendFile file . (++ "\n ") . show $ meal[m
[4m+[m[4m    file <- pure (\x -> mac ++ "/" ++ x ++ ".txt") <*> filename[m
[4m+[m[4m    contents <- if cmd == "workout"[m
[4m+[m[4m                    then W.insertWorkout >>= return . show[m
[4m+[m[4m                    else M.insertMeal >>= return . show[m
[4m+[m[4m    appendFile file . (++ "\n ") . show $ contents[m
[4m+[m[4m    return ()[m
[32m [m
[32m [m
[36mdiff --git a/src/workout.hs b/src/workout.hs[m
[36mindex e9189e6..4fb4405 100644[m
[36m--- a/src/workout.hs[m
[36m+++ b/src/workout.hs[m
[34m@@ -1,11 +1,24 @@[m
[32m module Workout([m
[32m               Workout(..)[m
[32m               , lossCalorie[m
[4m+[m							[4m, insertWorkout[m
[32m               , ) where[m
[32m [m
[32m import Data.Calorie[m
[32m [m
[1m-data Workout = Run | Swim | Bike | Walk deriving Eq[m
[1m-lossCalorie :: Workout -> Float -> Float -> Calorie[m
[4m+[m[4mdata Workout = Run | Swim | Bike | Walk deriving (Eq, Read)[m
[4m+[m[4mlossCalorie :: Workout -> Double -> Double -> Calorie[m
[32m lossCalorie Run weight km = Just $ weight * km[m
[32m lossCalorie _ _ _  = Nothing[m
[4m+[m
[4m+[m[4minsertWorkout :: IO Calorie[m
[4m+[m[4minsertWorkout = do[m
[4m+[m	[4mputStrLn "Workout Type"[m
[4m+[m	[4mwType <- fmap read getLine :: IO Workout[m
[4m+[m	[4mputStrLn "Weight (kg)"[m
[4m+[m	[4mkg <- fmap read getLine :: IO Double[m
[4m+[m	[4mputStrLn "Distance (km)"[m
[4m+[m	[4mdistance <- fmap read getLine :: IO Double[m
[4m+[m	[4mreturn $ lossCalorie wType kg distance[m
[7m+[m
[7m+[m