on master help sign in
Merge pull request #4465 from SPY/bugfix/compile-time-str-to-int

Fix discrepancy in behaviour of run-time and complile-time str-to-int…

commit88a9f38faff00b21603f74d52b2620bccb6f4745 authorNiklas Larsson <metaniklas@gmail.com> dateSun 10 Jun 2018, 13:19 (8 years ago) parent5be78107171465
1 file changed+5−1
src/Idris/Primitives.hs+5−1
src/Idris/Primitives.hs+5−1
@@ -416,9 +416,13 @@ getInt (BI x : xs) = x : getInt xs
416416getInt _ = []
417417
418418strToInt :: IntTy -> [Const] -> Maybe Const
419−strToInt ity [Str x] = case reads x of
419+strToInt ity [Str x] = case reads $ dropFirstPlus x of
420420 [(n,s)] -> Just $ if all isSpace s then toInt ity (n :: Integer) else I 0
421421 _ -> Just $ I 0
422+ where
423+ dropFirstPlus :: String -> String
424+ dropFirstPlus ('+' : str) = str
425+ dropFirstPlus str = str
422426strToInt _ _ = Nothing
423427
424428intToFloat :: [Const] -> Maybe Const