Skip to content

Instantly share code, notes, and snippets.

@glowcoil
Created February 6, 2010 01:05
Show Gist options
  • Save glowcoil/296442 to your computer and use it in GitHub Desktop.
Save glowcoil/296442 to your computer and use it in GitHub Desktop.
number = do w <- whole
return $ Number $ read w
<|> do f <- fraction
return $ Number $ read ('0':f)
<|> do w <- whole
f <- fraction
return $ Number $ read (w ++ f)
where whole = many1 digit
fraction = do char '.'
a <- many1 digit
return $ '.':a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment