summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-12-27 20:59:56 +1100
committerJed Barber <jjbarber@y7mail.com>2014-12-27 20:59:56 +1100
commitfcdda74a4dbbe515c0aad3f428fda3a46990c848 (patch)
treec04f5791806221664af709a34044cf80552134bf
parentc6ce42b8a322fa114eb1c2087e734333ac2fb634 (diff)
toInt improved
-rw-r--r--src/Grasp/Types/Instruction.hs7
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