-qvalue = do x ← char '0'
- xs ← option "" $
- do y ← char '.'
- ys ← atMost 3 digit
- return (y:ys)
- return $ read (x:xs)
- <|>
- do x ← char '1'
- xs ← option "" $
- do y ← char '.'
- ys ← atMost 3 (char '0')
- return (y:ys)
- return $ read (x:xs)
-
--- |@'atMost' n v@ is like @'P.many' v@ but applies the given action
--- at most @n@ times.
-atMost ∷ Alternative f ⇒ Int → f a → f [a]
-{-# INLINE atMost #-}
-atMost 0 _ = pure []
-atMost n v = ( (:) <$> v ⊛ atMost (n-1) v )
- <|>
- pure []