Safe Haskell | None |
---|---|
Language | Haskell2010 |
A natural number in a specified range (fixed and checked at compile-time)
Synopsis
- data NatRange (f :: Nat) (t :: Nat)
- pattern NatRange :: forall (f :: Nat) (t :: Nat). MakeNatRange f t => Natural -> NatRange f t
- natRange :: forall (n :: Nat) f t. (MakeNatRange f t, CheckInRange f t n, KnownNat n) => NatRange f t
- safeMakeNatRange :: forall f t. MakeNatRange f t => Natural -> Maybe (NatRange f t)
- makeNatRange :: forall f t. MakeNatRange f t => Natural -> NatRange f t
- unsafeMakeNatRange :: forall f t. MakeNatRange f t => Natural -> NatRange f t
- widenNatRange :: forall f2 t2 f1 t1. WidenNatRange f1 t1 f2 t2 => NatRange f1 t1 -> NatRange f2 t2
- (.++.) :: (MakeNatRange f1 t1, MakeNatRange f2 t2, MakeNatRange (f1 + f2) (t1 + t2)) => NatRange f1 t1 -> NatRange f2 t2 -> NatRange (f1 + f2) (t1 + t2)
Documentation
data NatRange (f :: Nat) (t :: Nat) Source #
A natural number in the specified range
Instances
(KnownNat (t - f), KnownNat t, KnownNat f, Num (BitNatWord (NatBitCount ((t - f) + 1))), Integral (BitNatWord (NatBitCount ((t - f) + 1)))) => Show (NatRange f t) Source # | Show instance for natural range |
pattern NatRange :: forall (f :: Nat) (t :: Nat). MakeNatRange f t => Natural -> NatRange f t Source #
Natural range pattern
>>>
NatRange @10 @12 11
NatRange @10 @12 11
natRange :: forall (n :: Nat) f t. (MakeNatRange f t, CheckInRange f t n, KnownNat n) => NatRange f t Source #
Create a value in a Natural range
safeMakeNatRange :: forall f t. MakeNatRange f t => Natural -> Maybe (NatRange f t) Source #
Create a value in a Natural range (check validity)
makeNatRange :: forall f t. MakeNatRange f t => Natural -> NatRange f t Source #
Create a value in a Natural range (check validity and throw on error)
unsafeMakeNatRange :: forall f t. MakeNatRange f t => Natural -> NatRange f t Source #
Create a value in a Natural range
widenNatRange :: forall f2 t2 f1 t1. WidenNatRange f1 t1 f2 t2 => NatRange f1 t1 -> NatRange f2 t2 Source #
Widen a natural
>>>
let a = NatRange @18 @100 25
>>>
widenNatRange @16 @200 a
NatRange @16 @200 25