Safe Haskell | None |
---|---|
Language | Haskell2010 |
- floating :: EffectiveDigit r => ByteString -> Maybe (r, ByteString)
- double :: ByteString -> Maybe (Double, ByteString)
- signed :: Num r => (ByteString -> Maybe (r, ByteString)) -> ByteString -> Maybe (r, ByteString)
- class (Fractional a, Num (Fraction a), Ord (Fraction a)) => EffectiveDigit a where
- class KnownNat n => Base n where
- floating10 :: forall r. EffectiveDigit r => ByteString -> Maybe (r, ByteString)
- floating' :: (Base b, EffectiveDigit r) => proxy b -> ByteString -> Maybe (r, ByteString)
functions
floating :: EffectiveDigit r => ByteString -> Maybe (r, ByteString) Source
convert bytestring into unsigned floating using radix.
this function can parse
- oct/hexa-decimal (0o,0O,0x,0X) (optional)
- floating(0.1, 12224.3543)
- exponential (e1, E+2, e-123) (10-radixed only, optional)
>>>
floating "12.4" :: Maybe (Double, ByteString)
Just (12.4,"")>>>
floating "1.23e12" :: Maybe (Double, ByteString)
Just (1.23e12,"")>>>
floating "0o0.4" :: Maybe (Double, ByteString)
Just (0.5,"")>>>
floating "0x3f.12" :: Maybe (Double, ByteString)
Just (63.0703125,"")
double :: ByteString -> Maybe (Double, ByteString) Source
double = floating
signed :: Num r => (ByteString -> Maybe (r, ByteString)) -> ByteString -> Maybe (r, ByteString) Source
convert unsigned parser to signed parser.
this function can parse
- sign (+, -) (optional)
>>>
signed double "12.4"
Just (12.4,"")>>>
signed double "-3.21e3"
Just (-3210.0,"")>>>
signed double "+0x1f.4"
Just (31.25,"")
classes
class (Fractional a, Num (Fraction a), Ord (Fraction a)) => EffectiveDigit a where Source
raw functions
floating10 :: forall r. EffectiveDigit r => ByteString -> Maybe (r, ByteString) Source
convert bytestring into unsigned floating using radix.
this function can parse
- floating(0.1, 12224.3543)
- exponential (e1, E+2, e-123) (optional)
>>>
floating10 "12.5" :: Maybe (Double, ByteString)
Just (12.5,"")>>>
floating10 "124.1e12" :: Maybe (Double, ByteString)
Just (1.241e14,"")>>>
floating10 "12.5e-3" :: Maybe (Double, ByteString)
Just (1.25e-2,"")>>>
floating10 "3.11e+3" :: Maybe (Double, ByteString)
Just (3110.0,"")
floating' :: (Base b, EffectiveDigit r) => proxy b -> ByteString -> Maybe (r, ByteString) Source
convert bytestring into unsigned floating using radix.
this function can parse
- floating(0.1, 12224.3543)
>>>
floating' (Proxy :: Proxy 36) "12z" :: Maybe (Double, ByteString)
Just (1403.0,"")>>>
floating' (Proxy :: Proxy 2) "1012" :: Maybe (Double, ByteString)
Just (5.0,"2")>>>
floating' (Proxy :: Proxy 10) "a12" :: Maybe (Double, ByteString)
Nothing