HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebin-0.1.4Haskell2010

Data.Wrd

Fixed-Wrdth (unsigned) integers.

  • 1 type
  • 22 values
  • Packagebin-0.1.4
  • Exports23
  • LanguageHaskell2010
  • LicenceGPL-2.0-or-later
  • SourceWrd.hs
datadata Wrd (n :: Nat) where
#

Fixed-width unsigned integers, Wrds for short.

The number is thought to be stored in big-endian format, i.e. most-significant bit first. (as in binary literals).

Constructors

Instances12Bounded, Eq, Num, Ord, Show, Bits, …
  • SNatI n => Bounded (Wrd n)Defined in bin-0.1.4 · Data.Wrd
  • Eq (Wrd n)Defined in bin-0.1.4 · Data.Wrd
  • SNatI n => Num (Wrd n)Defined in bin-0.1.4 · Data.Wrd
  • Ord (Wrd n)Defined in bin-0.1.4 · Data.Wrd
  • Show (Wrd n)Defined in bin-0.1.4 · Data.Wrd

    Wrd is printed as a binary literal.

    Example2 expressions
    let i = W1 $ W0 $ W1 $ W0 WEi0b1010
    Example1 expression
    explicitShow i"W1 $ W0 $ W1 $ W0 WE"

    At the time being, there is no Num instance.

  • SNatI n => Bits (Wrd n)Defined in bin-0.1.4 · Data.Wrd
    Example3 expressions
    let u = W0 $ W0 $ W1 $ W1 WElet v = W0 $ W1 $ W0 $ W1 WE(u, v)(0b0011,0b0101)
    Example1 expression
    (complement u, complement v)(0b1100,0b1010)
    Example1 expression
    (u .&. v, u .|. v, u `xor` v)(0b0001,0b0111,0b0110)
    Example1 expression
    (shiftR v 1, shiftL v 1)(0b0010,0b1010)
    Example1 expression
    (rotateR u 1, rotateL u 3)(0b1001,0b1001)
    Example1 expression
    popCount u2
  • SNatI n => FiniteBits (Wrd n)Defined in bin-0.1.4 · Data.Wrd
  • NFData (Wrd n)Defined in bin-0.1.4 · Data.Wrd
  • SNatI n => Arbitrary (Wrd n)Defined in bin-0.1.4 · Data.Wrd
  • CoArbitrary (Wrd n)Defined in bin-0.1.4 · Data.Wrd
  • SNatI n => Function (Wrd n)Defined in bin-0.1.4 · Data.Wrd
  • Hashable (Wrd n)Defined in bin-0.1.4 · Data.Wrd

Showing

2 declarations
valueexplicitShow :: Wrd n -> String
#

show displaying a structure of Wrd n

Example1 expression
explicitShow WE"WE"
Example1 expression
explicitShow $ W0 WE"W0 WE"
Example1 expression
explicitShow $ W1 $ W0 $ W1 $ W0 WE"W1 $ W0 $ W1 $ W0 WE"
valueexplicitShowsPrec :: Int -> Wrd n -> ShowS
#

showsPrec displaying a structure of Wrd n.

Example1 expression
explicitShowsPrec 0 (W0 WE) """W0 WE"
Example1 expression
explicitShowsPrec 1 (W0 WE) """(W0 WE)"

Conversions

1 declaration
valuetoNatural :: Wrd n -> Natural
#

Convert to Natural number

Example2 expressions
let u = W0 $ W1 $ W1 $ W1 $ W0 $ W1 $ W0 WEu0b0111010
Example1 expression
toNatural u58
Example1 expression
map toNatural (universe :: [Wrd N.Nat3])[0,1,2,3,4,5,6,7]

Universe

1 declaration
valueuniverse :: SNatI n => [Wrd n]
#

All values, i.e. universe of Wrd .

Example1 expression
universe :: [Wrd 'Z][WE]
Example1 expression
universe :: [Wrd N.Nat3][0b000,0b001,0b010,0b011,0b100,0b101,0b110,0b111]

Bits

14 declarations

We have implementation of some Bits members, which doesn't need SNatI constraint.

Extras

4 declarations