Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

parse rationals

  • Loading branch information...
commit 6ab3f7c3168b0215bb66405283b51879fef12d6e 1 parent 945543d
@yaxu authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 Parse.hs
View
7 Parse.hs
@@ -36,6 +36,9 @@ instance Parseable Bool where
instance Parseable Int where
p = parseRhythm pInt
+instance Parseable Rational where
+ p = parseRhythm pRational
+
type ColourD = Colour Double
instance Parseable ColourD where
@@ -160,6 +163,10 @@ pRatio = do n <- natural <?> "numerator"
return 1
return $ n % d
+pRational :: Parser (Sequence Rational)
+pRational = do r <- pRatio
+ return $ atom r
+
pDensity :: Parser (Rational)
pDensity = angles (pRatio <?> "ratio")
<|>
Please sign in to comment.
Something went wrong with that request. Please try again.