diff options
author | Jed Barber <jjbarber@y7mail.com> | 2014-12-27 20:59:56 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2014-12-27 20:59:56 +1100 |
commit | fcdda74a4dbbe515c0aad3f428fda3a46990c848 (patch) | |
tree | c04f5791806221664af709a34044cf80552134bf | |
parent | c6ce42b8a322fa114eb1c2087e734333ac2fb634 (diff) |
toInt improved
-rw-r--r-- | src/Grasp/Types/Instruction.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Grasp/Types/Instruction.hs b/src/Grasp/Types/Instruction.hs index e618222..f00d2df 100644 --- a/src/Grasp/Types/Instruction.hs +++ b/src/Grasp/Types/Instruction.hs @@ -32,5 +32,10 @@ toFloat :: Instruction -> Maybe Float toFloat (Instruction i) = readMaybe i toInt :: Instruction -> Maybe Int -toInt (Instruction i) = readMaybe i +toInt (Instruction i) = do + f <- (readMaybe :: String -> Maybe Float) i + let g = round f + h = fromIntegral g + r <- if (f == h) then Just g else Nothing + return r |