Safe Haskell | None |
---|---|
Language | Haskell2010 |
Provides the FromRational
and 'ToRational typeclasses.
Since: 0.1
Synopsis
- class FromInteger a => FromRational a where
- fromℚ :: (FromRational a, HasCallStack) => Rational -> a
- class ToReal a => ToRational a where
- toℚ :: (HasCallStack, ToRational a) => a -> Rational
Documentation
class FromInteger a => FromRational a where Source #
Replaces base's fromRational
functionality for when we do not have a
Fractional
instance.
5.5 :: Fractional a => a -- becomes fromQ 5.5 :: FromRational a => a
Note that fromRational
's deficiencies are inherited e.g. Natural
is
partial, bounded types have over/underflow issues.
Since: 0.1
Instances
FromRational Double Source # | Since: 0.1 |
FromRational Float Source # | Since: 0.1 |
RealFloat a => FromRational (Complex a) Source # | Since: 0.1 |
FromRational (Ratio Integer) Source # | Since: 0.1 |
FromRational (Ratio Natural) Source # | WARNING: Partial Since: 0.1 |
fromℚ :: (FromRational a, HasCallStack) => Rational -> a Source #
Unicode alias for fromQ
, with U+211A.
Since: 0.1
class ToReal a => ToRational a where Source #
Rational embedding.
Since: 0.1
Instances
ToRational Int16 Source # | Since: 0.1 |
ToRational Int32 Source # | Since: 0.1 |
ToRational Int64 Source # | Since: 0.1 |
ToRational Int8 Source # | Since: 0.1 |
ToRational Word16 Source # | Since: 0.1 |
ToRational Word32 Source # | Since: 0.1 |
ToRational Word64 Source # | Since: 0.1 |
ToRational Word8 Source # | Since: 0.1 |
ToRational Integer Source # | Since: 0.1 |
ToRational Natural Source # | Since: 0.1 |
ToRational Double Source # | Since: 0.1 |
ToRational Float Source # | Since: 0.1 |
ToRational Int Source # | Since: 0.1 |
ToRational Word Source # | Since: 0.1 |
ToRational (Ratio Integer) Source # | Since: 0.1 |
ToRational (Ratio Natural) Source # | Since: 0.1 |
toℚ :: (HasCallStack, ToRational a) => a -> Rational Source #
Unicode alias for toQ
, with U+211A.
Since: 0.1