Copyright | Copyright (c) 2016 the Hakaru team |
---|---|
License | BSD3 |
Maintainer | wren@community.haskell.org |
Stability | experimental |
Portability | Haskell98 + CPP |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
A data type for natural numbers (aka non-negative integers).
Documentation
Natural numbers, with fixed-width à la Int
. N.B., the Num
instance will throw errors on subtraction, negation, and
fromInteger
when the result is not a natural number.
Instances
Enum Nat Source # | |
Eq Nat Source # | |
Integral Nat Source # | |
Data Nat Source # | |
Defined in Data.Number.Nat gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Nat -> c Nat # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Nat # dataTypeOf :: Nat -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Nat) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Nat) # gmapT :: (forall b. Data b => b -> b) -> Nat -> Nat # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Nat -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Nat -> r # gmapQ :: (forall d. Data d => d -> u) -> Nat -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Nat -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Nat -> m Nat # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Nat -> m Nat # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Nat -> m Nat # | |
Num Nat Source # | |
Ord Nat Source # | |
Read Nat Source # | |
Real Nat Source # | |
Defined in Data.Number.Nat toRational :: Nat -> Rational # | |
Show Nat Source # | |
toNat :: Int -> Maybe Nat Source #
Safely convert an integer to a natural number. Returns Nothing
if the integer is negative.
unsafeNat :: Int -> Nat Source #
Unsafely convert an integer to a natural number. Throws an error if the integer is negative.