clash-prelude-0.99.2: CAES Language for Synchronous Hardware - Prelude library

Clash.Prelude.Safe

Description

This is the Safe API only of Clash.Prelude

CλaSH (pronounced ‘clash’) is a functional hardware description language that borrows both its syntax and semantics from the functional programming language Haskell. The merits of using a functional language to describe hardware comes from the fact that combinational circuits can be directly modeled as mathematical functions and that functional languages lend themselves very well at describing and (de-)composing mathematical functions.

This package provides:

• Prelude library containing datatypes and functions for circuit design

To use the library:

For now, Clash.Prelude is also the best starting point for exploring the library. A preliminary version of a tutorial can be found in Clash.Tutorial. Some circuit examples can be found in Clash.Examples.

Synopsis

# Creating synchronous sequential circuits

Arguments

 :: HiddenClockReset domain gated synchronous => (s -> i -> (s, o)) Transfer function in mealy machine form: state -> input -> (newstate,output) -> s Initial state -> Signal domain i -> Signal domain o Synchronous sequential function with input and output matching that of the mealy machine

Create a synchronous function from a combinational function describing a mealy machine

macT
:: Int        -- Current state
-> (Int,Int)  -- Input
-> (Int,Int)  -- (Updated state, output)
macT s (x,y) = (s',s)
where
s' = x * y + s

mac :: HiddenClockReset domain gated synchronous => Signal domain (Int, Int) -> Signal domain Int
mac = mealy macT 0

>>> simulate mac [(1,1),(2,2),(3,3),(4,4)]
[0,1,5,14...
...


Synchronous sequential functions can be composed just like their combinational counterpart:

dualMac
:: HiddenClockReset domain gated synchronous
=> (Signal domain Int, Signal domain Int)
-> (Signal domain Int, Signal domain Int)
-> Signal domain Int
dualMac (a,b) (x,y) = s1 + s2
where
s1 = mealy mac 0 (bundle (a,x))
s2 = mealy mac 0 (bundle (b,y))


Arguments

 :: (Bundle i, Bundle o, HiddenClockReset domain gated synchronous) => (s -> i -> (s, o)) Transfer function in mealy machine form: state -> input -> (newstate,output) -> s Initial state -> Unbundled domain i -> Unbundled domain o Synchronous sequential function with input and output matching that of the mealy machine

A version of mealy that does automatic Bundleing

Given a function f of type:

f :: Int -> (Bool, Int) -> (Int, (Int, Bool))


When we want to make compositions of f in g using mealy, we have to write:

g a b c = (b1,b2,i2)
where
(i1,b1) = unbundle (mealy f 0 (bundle (a,b)))
(i2,b2) = unbundle (mealy f 3 (bundle (i1,c)))


Using mealyB however we can write:

g a b c = (b1,b2,i2)
where
(i1,b1) = mealyB f 0 (a,b)
(i2,b2) = mealyB f 3 (i1,c)


Arguments

 :: (Bundle i, Bundle o, HiddenClockReset domain gated synchronous) => (s -> i -> (s, o)) Transfer function in mealy machine form: state -> input -> (newstate,output) -> s Initial state -> Unbundled domain i -> Unbundled domain o Synchronous sequential function with input and output matching that of the mealy machine

Infix version of mealyB

Arguments

 :: HiddenClockReset domain gated synchronous => (s -> i -> s) Transfer function in moore machine form: state -> input -> newstate -> (s -> o) Output function in moore machine form: state -> output -> s Initial state -> Signal domain i -> Signal domain o Synchronous sequential function with input and output matching that of the moore machine

Create a synchronous function from a combinational function describing a moore machine

macT :: Int        -- Current state
-> (Int,Int)  -- Input
-> Int        -- Updated state
macT s (x,y) = x * y + s

mac :: HiddenClockReset domain gated synchronous => Signal domain (Int, Int) -> Signal domain Int
mac = moore mac id 0

>>> simulate mac [(1,1),(2,2),(3,3),(4,4)]
[0,1,5,14...
...


Synchronous sequential functions can be composed just like their combinational counterpart:

dualMac
:: HiddenClockReset domain gated synchronous
=> (Signal domain Int, Signal domain Int)
-> (Signal domain Int, Signal domain Int)
-> Signal domain Int
dualMac (a,b) (x,y) = s1 + s2
where
s1 = moore mac id 0 (bundle (a,x))
s2 = moore mac id 0 (bundle (b,y))


Arguments

 :: (Bundle i, Bundle o, HiddenClockReset domain gated synchronous) => (s -> i -> s) Transfer function in moore machine form: state -> input -> newstate -> (s -> o) Output function in moore machine form: state -> output -> s Initial state -> Unbundled domain i -> Unbundled domain o Synchronous sequential function with input and output matching that of the moore machine

A version of moore that does automatic Bundleing

Given a functions t and o of types:

t :: Int -> (Bool, Int) -> Int
o :: Int -> (Int, Bool)


When we want to make compositions of t and o in g using moore, we have to write:

g a b c = (b1,b2,i2)
where
(i1,b1) = unbundle (moore t o 0 (bundle (a,b)))
(i2,b2) = unbundle (moore t o 3 (bundle (i1,c)))


Using mooreB however we can write:

g a b c = (b1,b2,i2)
where
(i1,b1) = mooreB t o 0 (a,b)
(i2,b2) = mooreB t o 3 (i1,c)


registerB :: (HiddenClockReset domain gated synchronous, Bundle a) => a -> Unbundled domain a -> Unbundled domain a infixr 3 Source #

Create a register function for product-type like signals (e.g. '(Signal a, Signal b)')

rP :: HiddenClockReset domain gated synchronous
=> (Signal domain Int, Signal domain Int)
-> (Signal domain Int, Signal domain Int)
rP = registerB (8,8)
>>> simulateB rP [(1,1),(2,2),(3,3)] :: [(Int,Int)]
[(8,8),(1,1),(2,2),(3,3)...
...


# ROMs

Arguments

 :: (KnownNat n, Enum addr) => Vec n a ROM contentNB: must be a constant -> addr Read address rd -> a The value of the ROM at address rd

An asynchronous/combinational ROM with space for n elements

Arguments

 :: KnownNat n => Vec (2 ^ n) a ROM contentNB: must be a constant -> Unsigned n Read address rd -> a The value of the ROM at address rd

An asynchronous/combinational ROM with space for 2^n elements

Arguments

 :: (KnownNat n, KnownNat m, HiddenClock domain gated) => Vec n a ROM contentNB: must be a constant -> Signal domain (Unsigned m) Read address rd -> Signal domain a The value of the ROM at address rd

A ROM with a synchronous read port, with space for n elements

• NB: Read value is delayed by 1 cycle
• NB: Initial output value is undefined

Arguments

 :: (KnownNat n, HiddenClock domain gated) => Vec (2 ^ n) a ROM contentNB: must be a constant -> Signal domain (Unsigned n) Read address rd -> Signal domain a The value of the ROM at address rd

A ROM with a synchronous read port, with space for 2^n elements

• NB: Read value is delayed by 1 cycle
• NB: Initial output value is undefined

# RAM primitives with a combinational read port

Arguments

 :: (Enum addr, HiddenClock domain gated, HasCallStack) => SNat n Size n of the RAM -> Signal domain addr Read address r -> Signal domain (Maybe (addr, a)) (write address w, value to write) -> Signal domain a Value of the RAM at address r

Create a RAM with space for n elements.

• NB: Initial content of the RAM is undefined

Arguments

 :: (KnownNat n, HiddenClock domain gated, HasCallStack) => Signal domain (Unsigned n) Read address r -> Signal domain (Maybe (Unsigned n, a)) (write address w, value to write) -> Signal domain a Value of the RAM at address r

Create a RAM with space for 2^n elements

• NB: Initial content of the RAM is undefined

# BlockRAM primitives

Arguments

 :: (Enum addr, HiddenClock domain gated, HasCallStack) => Vec n a Initial content of the BRAM, also determines the size, n, of the BRAM.NB: MUST be a constant. -> Signal domain addr Read address r -> Signal domain (Maybe (addr, a)) (write address w, value to write) -> Signal domain a Value of the blockRAM at address r from the previous clock cycle

Create a blockRAM with space for n elements.

• NB: Read value is delayed by 1 cycle
• NB: Initial output value is undefined
bram40
:: HiddenClock domain
=> Signal domain (Unsigned 6)
-> Signal domain (Maybe (Unsigned 6, Bit))
-> Signal domain Bit
bram40 = blockRam (replicate d40 1)


• See Clash.Prelude.BlockRam for more information on how to use a Block RAM.
• Use the adapter readNew for obtaining write-before-read semantics like this: readNew (blockRam inits) rd wrM.

Arguments

 :: (KnownNat n, HiddenClock domain gated, HasCallStack) => Vec (2 ^ n) a Initial content of the BRAM, also determines the size, 2^n, of the BRAM.NB: MUST be a constant. -> Signal domain (Unsigned n) Read address r -> Signal domain (Maybe (Unsigned n, a)) (write address w, value to write) -> Signal domain a Value of the blockRAM at address r from the previous clock cycle

Create a blockRAM with space for 2^n elements

• NB: Read value is delayed by 1 cycle
• NB: Initial output value is undefined
bram32
:: HiddenClock domain
=> Signal domain (Unsigned 5)
-> Signal domain (Maybe (Unsigned 5, Bit))
-> Signal domain Bit
bram32 = blockRamPow2 (replicate d32 1)


• See Clash.Prelude.BlockRam for more information on how to use a Block RAM.
• Use the adapter readNew for obtaining write-before-read semantics like this: readNew (blockRamPow2 inits) rd wrM.

Arguments

 :: (Eq addr, HiddenClockReset domain gated synchronous) => (Signal domain addr -> Signal domain (Maybe (addr, a)) -> Signal domain a) The ram component -> Signal domain addr Read address r -> Signal domain (Maybe (addr, a)) (Write address w, value to write) -> Signal domain a Value of the ram at address r from the previous clock cycle

>>> import Clash.Prelude
>>> :t readNew (blockRam (0 :> 1 :> Nil))
readNew (blockRam (0 :> 1 :> Nil))
:: ...
... =>
-> Signal domain (Maybe (addr, a)) -> Signal domain a


# Utility functions

Arguments

 :: (HiddenClockReset domain gated synchronous, Bounded a, Eq a) => a Starting value -> Signal domain a -> Signal domain Bool

Give a pulse when the Signal goes from minBound to maxBound

Arguments

 :: (HiddenClockReset domain gated synchronous, Bounded a, Eq a) => a Starting value -> Signal domain a -> Signal domain Bool

Give a pulse when the Signal goes from maxBound to minBound

riseEvery :: HiddenClockReset domain gated synchronous => SNat n -> Signal domain Bool Source #

Give a pulse every n clock cycles. This is a useful helper function when combined with functions like regEn or mux, in order to delay a register by a known amount.

To be precise: the given signal will be False for the next n-1 cycles, followed by a single True value:

>>> Prelude.last (sampleN 1024 (riseEvery d1024)) == True
True
>>> Prelude.or (sampleN 1023 (riseEvery d1024)) == False
True


For example, to update a counter once every 10 million cycles:

counter = regEn 0 (riseEvery (SNat :: SNat 10000000)) (counter + 1)


oscillate :: HiddenClockReset domain gated synchronous => Bool -> SNat n -> Signal domain Bool Source #

Oscillate a Bool for a given number of cycles. This is a convenient function when combined with something like regEn, as it allows you to easily hold a register value for a given number of cycles. The input Bool determines what the initial value is.

To oscillate on an interval of 5 cycles:

>>> sampleN 10 (oscillate False d5)
[False,False,False,False,False,True,True,True,True,True]


To oscillate between True and False:

>>> sampleN 10 (oscillate False d1)
[False,True,False,True,False,True,False,True,False,True]


An alternative definition for the above could be:

>>> let osc' = register False (not <$> osc') >>> let sample' = sampleN 200 >>> sample' (oscillate False d1) == sample' osc' True  # Exported modules ## Synchronous signals ## DataFlow interface ## Datatypes ### Bit vectors ### Arbitrary-width numbers ### Fixed point numbers ### Fixed size vectors ### Perfect depth trees ## Annotations ## Type-level natural numbers ## Type-level strings ## Type classes ### Clash ### Other module Data.Bits ## Exceptions ## Named types ## Hidden arguments ## Haskell Prelude Clash.Prelude re-exports most of the Haskell Prelude with the exception of the following: (++), (!!), concat, drop, foldl, foldl1, foldr, foldr1, head, init, iterate, last, length, map, repeat, replicate, reverse, scanl, scanr, splitAt, tail, take, unzip, unzip3, zip, zip3, zipWith, zipWith3. It instead exports the identically named functions defined in terms of Vec at Clash.Sized.Vector. seq :: a -> b -> b # The value of seq a b is bottom if a is bottom, and otherwise equal to b. In other words, it evaluates the first argument a to weak head normal form (WHNF). seq is usually introduced to improve performance by avoiding unneeded laziness. A note on evaluation order: the expression seq a b does not guarantee that a will be evaluated before b. The only guarantee given by seq is that the both a and b will be evaluated before seq returns a value. In particular, this means that b may be evaluated before a. If you need to guarantee a specific order of evaluation, you must use the function pseq from the "parallel" package. filter :: (a -> Bool) -> [a] -> [a] # filter, applied to a predicate and a list, returns the list of those elements that satisfy the predicate; i.e., filter p xs = [ x | x <- xs, p x] print :: Show a => a -> IO () # The print function outputs a value of any printable type to the standard output device. Printable types are those that are instances of class Show; print converts values to strings for output using the show operation and adds a newline. For example, a program to print the first 20 integers and their powers of 2 could be written as: main = print ([(n, 2^n) | n <- [0..19]]) fst :: (a, b) -> a # Extract the first component of a pair. snd :: (a, b) -> b # Extract the second component of a pair. otherwise is defined as the value True. It helps to make guards more readable. eg.  f x | x < 0 = ... | otherwise = ... ($) :: (a -> b) -> a -> b infixr 0 #

Application operator. This operator is redundant, since ordinary application (f x) means the same as (f $x). However, $ has low, right-associative binding precedence, so it sometimes allows parentheses to be omitted; for example:

f $g$ h x  =  f (g (h x))

It is also useful in higher-order situations, such as map ($0) xs, or zipWith ($) fs xs.

fromIntegral :: (Integral a, Num b) => a -> b #

general coercion from integral types

realToFrac :: (Real a, Fractional b) => a -> b #

general coercion to fractional types

class Bounded a where #

The Bounded class is used to name the upper and lower limits of a type. Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.

The Bounded class may be derived for any enumeration type; minBound is the first constructor listed in the data declaration and maxBound is the last. Bounded may also be derived for single-constructor datatypes whose constituent types are in Bounded.

Minimal complete definition

Methods

minBound :: a #

maxBound :: a #

Instances
 Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-4.10.0.0 Instance detailsDefined in GHC.Enum Methods Since: base-4.10.0.0 Instance detailsDefined in GHC.Enum Methods Bounded () Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: () #maxBound :: () # Instance detailsDefined in Data.Semigroup.Internal Methods Instance detailsDefined in Data.Semigroup.Internal Methods Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in GHC.Unicode Methods # Instance detailsDefined in Clash.Sized.Internal.BitVector Methods a :=> (Bounded (Dict a)) Instance detailsDefined in Data.Constraint Methodsins :: a :- Bounded (Dict a) () :=> (Bounded Bool) Instance detailsDefined in Data.Constraint Methodsins :: () :- Bounded Bool () :=> (Bounded Char) Instance detailsDefined in Data.Constraint Methodsins :: () :- Bounded Char () :=> (Bounded Int) Instance detailsDefined in Data.Constraint Methodsins :: () :- Bounded Int () :=> (Bounded Ordering) Instance detailsDefined in Data.Constraint Methodsins :: () :- Bounded Ordering () :=> (Bounded Word) Instance detailsDefined in Data.Constraint Methodsins :: () :- Bounded Word () :=> (Bounded ()) Instance detailsDefined in Data.Constraint Methodsins :: () :- Bounded () Class () (Bounded a) Instance detailsDefined in Data.Constraint Methodscls :: Bounded a :- () Bounded a => Bounded (Min a) Instance detailsDefined in Data.Semigroup MethodsminBound :: Min a #maxBound :: Min a # Bounded a => Bounded (Max a) Instance detailsDefined in Data.Semigroup MethodsminBound :: Max a #maxBound :: Max a # Bounded a => Bounded (First a) Instance detailsDefined in Data.Semigroup Methods Bounded a => Bounded (Last a) Instance detailsDefined in Data.Semigroup Methods Bounded m => Bounded (WrappedMonoid m) Instance detailsDefined in Data.Semigroup Methods Bounded a => Bounded (Identity a) Instance detailsDefined in Data.Functor.Identity Methods Bounded a => Bounded (Dual a) Instance detailsDefined in Data.Semigroup.Internal Methods Bounded a => Bounded (Sum a) Instance detailsDefined in Data.Semigroup.Internal MethodsminBound :: Sum a #maxBound :: Sum a # Bounded a => Bounded (Product a) Instance detailsDefined in Data.Semigroup.Internal Methods KnownNat n => Bounded (BitVector n) # Instance detailsDefined in Clash.Sized.Internal.BitVector Methods KnownNat n => Bounded (Index n) # Instance detailsDefined in Clash.Sized.Internal.Index Methods (Ord a, Num a) => Bounded (Bounds a) Instance detailsDefined in Test.QuickCheck.Arbitrary MethodsminBound :: Bounds a #maxBound :: Bounds a # KnownNat n => Bounded (Unsigned n) # Instance detailsDefined in Clash.Sized.Internal.Unsigned Methods KnownNat n => Bounded (Signed n) # Instance detailsDefined in Clash.Sized.Internal.Signed Methods a => Bounded (Dict a) Instance detailsDefined in Data.Constraint MethodsminBound :: Dict a #maxBound :: Dict a # (Bounded a) :=> (Bounded (Identity a)) Instance detailsDefined in Data.Constraint Methodsins :: Bounded a :- Bounded (Identity a) (Bounded a) :=> (Bounded (Const a b)) Instance detailsDefined in Data.Constraint Methodsins :: Bounded a :- Bounded (Const a b) (Bounded a, Bounded b) => Bounded (a, b) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b) #maxBound :: (a, b) # Bounded (Proxy t) Instance detailsDefined in Data.Proxy Methods (Bounded a, Bounded b) :=> (Bounded (a, b)) Instance detailsDefined in Data.Constraint Methodsins :: (Bounded a, Bounded b) :- Bounded (a, b) (Bounded a, Bounded b, Bounded c) => Bounded (a, b, c) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c) #maxBound :: (a, b, c) # Bounded a => Bounded (Const a b) Instance detailsDefined in Data.Functor.Const MethodsminBound :: Const a b #maxBound :: Const a b # a ~ b => Bounded (a :~: b) Since: base-4.7.0.0 Instance detailsDefined in Data.Type.Equality MethodsminBound :: a :~: b #maxBound :: a :~: b # Bounded b => Bounded (Tagged s b) Instance detailsDefined in Data.Tagged MethodsminBound :: Tagged s b #maxBound :: Tagged s b # Bounded (rep (int + frac)) => Bounded (Fixed rep int frac) # Instance detailsDefined in Clash.Sized.Fixed MethodsminBound :: Fixed rep int frac #maxBound :: Fixed rep int frac # (Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d) #maxBound :: (a, b, c, d) # a ~~ b => Bounded (a :~~: b) Since: base-4.10.0.0 Instance detailsDefined in Data.Type.Equality MethodsminBound :: a :~~: b #maxBound :: a :~~: b # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded (a, b, c, d, e) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e) #maxBound :: (a, b, c, d, e) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f) => Bounded (a, b, c, d, e, f) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f) #maxBound :: (a, b, c, d, e, f) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g) => Bounded (a, b, c, d, e, f, g) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g) #maxBound :: (a, b, c, d, e, f, g) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h) => Bounded (a, b, c, d, e, f, g, h) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h) #maxBound :: (a, b, c, d, e, f, g, h) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i) => Bounded (a, b, c, d, e, f, g, h, i) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i) #maxBound :: (a, b, c, d, e, f, g, h, i) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j) => Bounded (a, b, c, d, e, f, g, h, i, j) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j) #maxBound :: (a, b, c, d, e, f, g, h, i, j) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k) => Bounded (a, b, c, d, e, f, g, h, i, j, k) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n, Bounded o) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) #

class Enum a where #

Class Enum defines operations on sequentially ordered types.

The enumFrom... methods are used in Haskell's translation of arithmetic sequences.

Instances of Enum may be derived for any enumeration type (types whose constructors have no fields). The nullary constructors are assumed to be numbered left-to-right by fromEnum from 0 through n-1. See Chapter 10 of the Haskell Report for more details.

For any type that is an instance of class Bounded as well as Enum, the following should hold:

• The calls succ maxBound and pred minBound should result in a runtime error.
• fromEnum and toEnum should give a runtime error if the result value is not representable in the result type. For example, toEnum 7 :: Bool is an error.
• enumFrom and enumFromThen should be defined with an implicit bound, thus:
   enumFrom     x   = enumFromTo     x maxBound
enumFromThen x y = enumFromThenTo x y bound
where
| otherwise                = minBound

Minimal complete definition

Methods

succ :: a -> a #

the successor of a value. For numeric types, succ adds 1.

pred :: a -> a #

the predecessor of a value. For numeric types, pred subtracts 1.

toEnum :: Int -> a #

Convert from an Int.

fromEnum :: a -> Int #

Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.

enumFrom :: a -> [a] #

Used in Haskell's translation of [n..].

enumFromThen :: a -> a -> [a] #

Used in Haskell's translation of [n,n'..].

enumFromTo :: a -> a -> [a] #

Used in Haskell's translation of [n..m].

enumFromThenTo :: a -> a -> a -> [a] #

Used in Haskell's translation of [n,n'..m].

Instances
 Since: base-2.1 Instance detailsDefined in GHC.Enum Methodssucc :: Bool -> Bool #pred :: Bool -> Bool #toEnum :: Int -> Bool #fromEnum :: Bool -> Int #enumFrom :: Bool -> [Bool] #enumFromThen :: Bool -> Bool -> [Bool] #enumFromTo :: Bool -> Bool -> [Bool] #enumFromThenTo :: Bool -> Bool -> Bool -> [Bool] # Since: base-2.1 Instance detailsDefined in GHC.Enum Methodssucc :: Char -> Char #pred :: Char -> Char #toEnum :: Int -> Char #fromEnum :: Char -> Int #enumFrom :: Char -> [Char] #enumFromThen :: Char -> Char -> [Char] #enumFromTo :: Char -> Char -> [Char] #enumFromThenTo :: Char -> Char -> Char -> [Char] # Since: base-2.1 Instance detailsDefined in GHC.Enum Methodssucc :: Int -> Int #pred :: Int -> Int #toEnum :: Int -> Int #fromEnum :: Int -> Int #enumFrom :: Int -> [Int] #enumFromThen :: Int -> Int -> [Int] #enumFromTo :: Int -> Int -> [Int] #enumFromThenTo :: Int -> Int -> Int -> [Int] # Since: base-2.1 Instance detailsDefined in GHC.Int Methodssucc :: Int8 -> Int8 #pred :: Int8 -> Int8 #toEnum :: Int -> Int8 #fromEnum :: Int8 -> Int #enumFrom :: Int8 -> [Int8] #enumFromThen :: Int8 -> Int8 -> [Int8] #enumFromTo :: Int8 -> Int8 -> [Int8] #enumFromThenTo :: Int8 -> Int8 -> Int8 -> [Int8] # Since: base-2.1 Instance detailsDefined in GHC.Int Methodssucc :: Int16 -> Int16 #pred :: Int16 -> Int16 #toEnum :: Int -> Int16 #enumFrom :: Int16 -> [Int16] #enumFromThen :: Int16 -> Int16 -> [Int16] #enumFromTo :: Int16 -> Int16 -> [Int16] #enumFromThenTo :: Int16 -> Int16 -> Int16 -> [Int16] # Since: base-2.1 Instance detailsDefined in GHC.Int Methodssucc :: Int32 -> Int32 #pred :: Int32 -> Int32 #toEnum :: Int -> Int32 #enumFrom :: Int32 -> [Int32] #enumFromThen :: Int32 -> Int32 -> [Int32] #enumFromTo :: Int32 -> Int32 -> [Int32] #enumFromThenTo :: Int32 -> Int32 -> Int32 -> [Int32] # Since: base-2.1 Instance detailsDefined in GHC.Int Methodssucc :: Int64 -> Int64 #pred :: Int64 -> Int64 #toEnum :: Int -> Int64 #enumFrom :: Int64 -> [Int64] #enumFromThen :: Int64 -> Int64 -> [Int64] #enumFromTo :: Int64 -> Int64 -> [Int64] #enumFromThenTo :: Int64 -> Int64 -> Int64 -> [Int64] # Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsenumFrom :: Integer -> [Integer] #enumFromThen :: Integer -> Integer -> [Integer] #enumFromTo :: Integer -> Integer -> [Integer] #enumFromThenTo :: Integer -> Integer -> Integer -> [Integer] # Since: base-4.8.0.0 Instance detailsDefined in GHC.Natural MethodsenumFrom :: Natural -> [Natural] #enumFromThen :: Natural -> Natural -> [Natural] #enumFromTo :: Natural -> Natural -> [Natural] #enumFromThenTo :: Natural -> Natural -> Natural -> [Natural] # Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsenumFrom :: Ordering -> [Ordering] #enumFromTo :: Ordering -> Ordering -> [Ordering] # Since: base-2.1 Instance detailsDefined in GHC.Enum Methodssucc :: Word -> Word #pred :: Word -> Word #toEnum :: Int -> Word #fromEnum :: Word -> Int #enumFrom :: Word -> [Word] #enumFromThen :: Word -> Word -> [Word] #enumFromTo :: Word -> Word -> [Word] #enumFromThenTo :: Word -> Word -> Word -> [Word] # Since: base-2.1 Instance detailsDefined in GHC.Word Methodssucc :: Word8 -> Word8 #pred :: Word8 -> Word8 #toEnum :: Int -> Word8 #enumFrom :: Word8 -> [Word8] #enumFromThen :: Word8 -> Word8 -> [Word8] #enumFromTo :: Word8 -> Word8 -> [Word8] #enumFromThenTo :: Word8 -> Word8 -> Word8 -> [Word8] # Since: base-2.1 Instance detailsDefined in GHC.Word MethodstoEnum :: Int -> Word16 #enumFrom :: Word16 -> [Word16] #enumFromThen :: Word16 -> Word16 -> [Word16] #enumFromTo :: Word16 -> Word16 -> [Word16] #enumFromThenTo :: Word16 -> Word16 -> Word16 -> [Word16] # Since: base-2.1 Instance detailsDefined in GHC.Word MethodstoEnum :: Int -> Word32 #enumFrom :: Word32 -> [Word32] #enumFromThen :: Word32 -> Word32 -> [Word32] #enumFromTo :: Word32 -> Word32 -> [Word32] #enumFromThenTo :: Word32 -> Word32 -> Word32 -> [Word32] # Since: base-2.1 Instance detailsDefined in GHC.Word MethodstoEnum :: Int -> Word64 #enumFrom :: Word64 -> [Word64] #enumFromThen :: Word64 -> Word64 -> [Word64] #enumFromTo :: Word64 -> Word64 -> [Word64] #enumFromThenTo :: Word64 -> Word64 -> Word64 -> [Word64] # Since: base-4.10.0.0 Instance detailsDefined in GHC.Enum MethodsenumFrom :: VecCount -> [VecCount] #enumFromTo :: VecCount -> VecCount -> [VecCount] # Since: base-4.10.0.0 Instance detailsDefined in GHC.Enum MethodsenumFrom :: VecElem -> [VecElem] #enumFromThen :: VecElem -> VecElem -> [VecElem] #enumFromTo :: VecElem -> VecElem -> [VecElem] #enumFromThenTo :: VecElem -> VecElem -> VecElem -> [VecElem] # Enum () Since: base-2.1 Instance detailsDefined in GHC.Enum Methodssucc :: () -> () #pred :: () -> () #toEnum :: Int -> () #fromEnum :: () -> Int #enumFrom :: () -> [()] #enumFromThen :: () -> () -> [()] #enumFromTo :: () -> () -> [()] #enumFromThenTo :: () -> () -> () -> [()] # Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in Foreign.C.Types Methodssucc :: CChar -> CChar #pred :: CChar -> CChar #toEnum :: Int -> CChar #enumFrom :: CChar -> [CChar] #enumFromThen :: CChar -> CChar -> [CChar] #enumFromTo :: CChar -> CChar -> [CChar] #enumFromThenTo :: CChar -> CChar -> CChar -> [CChar] # Instance detailsDefined in Foreign.C.Types MethodstoEnum :: Int -> CSChar #enumFrom :: CSChar -> [CSChar] #enumFromThen :: CSChar -> CSChar -> [CSChar] #enumFromTo :: CSChar -> CSChar -> [CSChar] #enumFromThenTo :: CSChar -> CSChar -> CSChar -> [CSChar] # Instance detailsDefined in Foreign.C.Types MethodstoEnum :: Int -> CUChar #enumFrom :: CUChar -> [CUChar] #enumFromThen :: CUChar -> CUChar -> [CUChar] #enumFromTo :: CUChar -> CUChar -> [CUChar] #enumFromThenTo :: CUChar -> CUChar -> CUChar -> [CUChar] # Instance detailsDefined in Foreign.C.Types MethodstoEnum :: Int -> CShort #enumFrom :: CShort -> [CShort] #enumFromThen :: CShort -> CShort -> [CShort] #enumFromTo :: CShort -> CShort -> [CShort] #enumFromThenTo :: CShort -> CShort -> CShort -> [CShort] # Instance detailsDefined in Foreign.C.Types MethodsenumFrom :: CUShort -> [CUShort] #enumFromThen :: CUShort -> CUShort -> [CUShort] #enumFromTo :: CUShort -> CUShort -> [CUShort] #enumFromThenTo :: CUShort -> CUShort -> CUShort -> [CUShort] # Instance detailsDefined in Foreign.C.Types Methodssucc :: CInt -> CInt #pred :: CInt -> CInt #toEnum :: Int -> CInt #fromEnum :: CInt -> Int #enumFrom :: CInt -> [CInt] #enumFromThen :: CInt -> CInt -> [CInt] #enumFromTo :: CInt -> CInt -> [CInt] #enumFromThenTo :: CInt -> CInt -> CInt -> [CInt] # Instance detailsDefined in Foreign.C.Types Methodssucc :: CUInt -> CUInt #pred :: CUInt -> CUInt #toEnum :: Int -> CUInt #enumFrom :: CUInt -> [CUInt] #enumFromThen :: CUInt -> CUInt -> [CUInt] #enumFromTo :: CUInt -> CUInt -> [CUInt] #enumFromThenTo :: CUInt -> CUInt -> CUInt -> [CUInt] # Instance detailsDefined in Foreign.C.Types Methodssucc :: CLong -> CLong #pred :: CLong -> CLong #toEnum :: Int -> CLong #enumFrom :: CLong -> [CLong] #enumFromThen :: CLong -> CLong -> [CLong] #enumFromTo :: CLong -> CLong -> [CLong] #enumFromThenTo :: CLong -> CLong -> CLong -> [CLong] # Instance detailsDefined in Foreign.C.Types MethodstoEnum :: Int -> CULong #enumFrom :: CULong -> [CULong] #enumFromThen :: CULong -> CULong -> [CULong] #enumFromTo :: CULong -> CULong -> [CULong] #enumFromThenTo :: CULong -> CULong -> CULong -> [CULong] # Instance detailsDefined in Foreign.C.Types MethodstoEnum :: Int -> CLLong #enumFrom :: CLLong -> [CLLong] #enumFromThen :: CLLong -> CLLong -> [CLLong] #enumFromTo :: CLLong -> CLLong -> [CLLong] #enumFromThenTo :: CLLong -> CLLong -> CLLong -> [CLLong] # Instance detailsDefined in Foreign.C.Types MethodsenumFrom :: CULLong -> [CULLong] #enumFromThen :: CULLong -> CULLong -> [CULLong] #enumFromTo :: CULLong -> CULLong -> [CULLong] #enumFromThenTo :: CULLong -> CULLong -> CULLong -> [CULLong] # Instance detailsDefined in Foreign.C.Types Methodssucc :: CBool -> CBool #pred :: CBool -> CBool #toEnum :: Int -> CBool #enumFrom :: CBool -> [CBool] #enumFromThen :: CBool -> CBool -> [CBool] #enumFromTo :: CBool -> CBool -> [CBool] #enumFromThenTo :: CBool -> CBool -> CBool -> [CBool] # Instance detailsDefined in Foreign.C.Types MethodstoEnum :: Int -> CFloat #enumFrom :: CFloat -> [CFloat] #enumFromThen :: CFloat -> CFloat -> [CFloat] #enumFromTo :: CFloat -> CFloat -> [CFloat] #enumFromThenTo :: CFloat -> CFloat -> CFloat -> [CFloat] # Instance detailsDefined in Foreign.C.Types MethodsenumFrom :: CDouble -> [CDouble] #enumFromThen :: CDouble -> CDouble -> [CDouble] #enumFromTo :: CDouble -> CDouble -> [CDouble] #enumFromThenTo :: CDouble -> CDouble -> CDouble -> [CDouble] # Instance detailsDefined in Foreign.C.Types MethodsenumFrom :: CPtrdiff -> [CPtrdiff] #enumFromTo :: CPtrdiff -> CPtrdiff -> [CPtrdiff] # Instance detailsDefined in Foreign.C.Types Methodssucc :: CSize -> CSize #pred :: CSize -> CSize #toEnum :: Int -> CSize #enumFrom :: CSize -> [CSize] #enumFromThen :: CSize -> CSize -> [CSize] #enumFromTo :: CSize -> CSize -> [CSize] #enumFromThenTo :: CSize -> CSize -> CSize -> [CSize] # Instance detailsDefined in Foreign.C.Types MethodstoEnum :: Int -> CWchar #enumFrom :: CWchar -> [CWchar] #enumFromThen :: CWchar -> CWchar -> [CWchar] #enumFromTo :: CWchar -> CWchar -> [CWchar] #enumFromThenTo :: CWchar -> CWchar -> CWchar -> [CWchar] # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types MethodstoEnum :: Int -> CClock #enumFrom :: CClock -> [CClock] #enumFromThen :: CClock -> CClock -> [CClock] #enumFromTo :: CClock -> CClock -> [CClock] #enumFromThenTo :: CClock -> CClock -> CClock -> [CClock] # Instance detailsDefined in Foreign.C.Types Methodssucc :: CTime -> CTime #pred :: CTime -> CTime #toEnum :: Int -> CTime #enumFrom :: CTime -> [CTime] #enumFromThen :: CTime -> CTime -> [CTime] #enumFromTo :: CTime -> CTime -> [CTime] #enumFromThenTo :: CTime -> CTime -> CTime -> [CTime] # Instance detailsDefined in Foreign.C.Types MethodsenumFrom :: CUSeconds -> [CUSeconds] # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types MethodsenumFrom :: CIntPtr -> [CIntPtr] #enumFromThen :: CIntPtr -> CIntPtr -> [CIntPtr] #enumFromTo :: CIntPtr -> CIntPtr -> [CIntPtr] #enumFromThenTo :: CIntPtr -> CIntPtr -> CIntPtr -> [CIntPtr] # Instance detailsDefined in Foreign.C.Types MethodsenumFrom :: CUIntPtr -> [CUIntPtr] #enumFromTo :: CUIntPtr -> CUIntPtr -> [CUIntPtr] # Instance detailsDefined in Foreign.C.Types MethodsenumFrom :: CIntMax -> [CIntMax] #enumFromThen :: CIntMax -> CIntMax -> [CIntMax] #enumFromTo :: CIntMax -> CIntMax -> [CIntMax] #enumFromThenTo :: CIntMax -> CIntMax -> CIntMax -> [CIntMax] # Instance detailsDefined in Foreign.C.Types MethodsenumFrom :: CUIntMax -> [CUIntMax] #enumFromTo :: CUIntMax -> CUIntMax -> [CUIntMax] # Instance detailsDefined in GHC.Unicode Methods Instance detailsDefined in GHC.LanguageExtensions.Type MethodsenumFrom :: Extension -> [Extension] # Instance detailsDefined in Data.Time.Calendar.Days Methodssucc :: Day -> Day #pred :: Day -> Day #toEnum :: Int -> Day #fromEnum :: Day -> Int #enumFrom :: Day -> [Day] #enumFromThen :: Day -> Day -> [Day] #enumFromTo :: Day -> Day -> [Day] #enumFromThenTo :: Day -> Day -> Day -> [Day] # # Instance detailsDefined in Clash.Sized.Internal.BitVector Methodssucc :: Bit -> Bit #pred :: Bit -> Bit #toEnum :: Int -> Bit #fromEnum :: Bit -> Int #enumFrom :: Bit -> [Bit] #enumFromThen :: Bit -> Bit -> [Bit] #enumFromTo :: Bit -> Bit -> [Bit] #enumFromThenTo :: Bit -> Bit -> Bit -> [Bit] # a :=> (Enum (Dict a)) Instance detailsDefined in Data.Constraint Methodsins :: a :- Enum (Dict a) () :=> (Enum Bool) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum Bool () :=> (Enum Char) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum Char () :=> (Enum Double) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum Double () :=> (Enum Float) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum Float () :=> (Enum Int) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum Int () :=> (Enum Integer) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum Integer () :=> (Enum Natural) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum Natural () :=> (Enum Ordering) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum Ordering () :=> (Enum Word) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum Word () :=> (Enum ()) Instance detailsDefined in Data.Constraint Methodsins :: () :- Enum () Class () (Enum a) Instance detailsDefined in Data.Constraint Methodscls :: Enum a :- () Integral a => Enum (Ratio a) Since: base-2.0.1 Instance detailsDefined in GHC.Real Methodssucc :: Ratio a -> Ratio a #pred :: Ratio a -> Ratio a #toEnum :: Int -> Ratio a #fromEnum :: Ratio a -> Int #enumFrom :: Ratio a -> [Ratio a] #enumFromThen :: Ratio a -> Ratio a -> [Ratio a] #enumFromTo :: Ratio a -> Ratio a -> [Ratio a] #enumFromThenTo :: Ratio a -> Ratio a -> Ratio a -> [Ratio a] # Enum (Fixed a) Since: base-2.1 Instance detailsDefined in Data.Fixed Methodssucc :: Fixed a -> Fixed a #pred :: Fixed a -> Fixed a #toEnum :: Int -> Fixed a #fromEnum :: Fixed a -> Int #enumFrom :: Fixed a -> [Fixed a] #enumFromThen :: Fixed a -> Fixed a -> [Fixed a] #enumFromTo :: Fixed a -> Fixed a -> [Fixed a] #enumFromThenTo :: Fixed a -> Fixed a -> Fixed a -> [Fixed a] # Enum a => Enum (Min a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodssucc :: Min a -> Min a #pred :: Min a -> Min a #toEnum :: Int -> Min a #fromEnum :: Min a -> Int #enumFrom :: Min a -> [Min a] #enumFromThen :: Min a -> Min a -> [Min a] #enumFromTo :: Min a -> Min a -> [Min a] #enumFromThenTo :: Min a -> Min a -> Min a -> [Min a] # Enum a => Enum (Max a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodssucc :: Max a -> Max a #pred :: Max a -> Max a #toEnum :: Int -> Max a #fromEnum :: Max a -> Int #enumFrom :: Max a -> [Max a] #enumFromThen :: Max a -> Max a -> [Max a] #enumFromTo :: Max a -> Max a -> [Max a] #enumFromThenTo :: Max a -> Max a -> Max a -> [Max a] # Enum a => Enum (First a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodssucc :: First a -> First a #pred :: First a -> First a #toEnum :: Int -> First a #fromEnum :: First a -> Int #enumFrom :: First a -> [First a] #enumFromThen :: First a -> First a -> [First a] #enumFromTo :: First a -> First a -> [First a] #enumFromThenTo :: First a -> First a -> First a -> [First a] # Enum a => Enum (Last a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodssucc :: Last a -> Last a #pred :: Last a -> Last a #toEnum :: Int -> Last a #fromEnum :: Last a -> Int #enumFrom :: Last a -> [Last a] #enumFromThen :: Last a -> Last a -> [Last a] #enumFromTo :: Last a -> Last a -> [Last a] #enumFromThenTo :: Last a -> Last a -> Last a -> [Last a] # Enum a => Enum (WrappedMonoid a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup MethodsenumFrom :: WrappedMonoid a -> [WrappedMonoid a] #enumFromThen :: WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a] #enumFromTo :: WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a] #enumFromThenTo :: WrappedMonoid a -> WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a] # Enum a => Enum (Identity a) Instance detailsDefined in Data.Functor.Identity Methodssucc :: Identity a -> Identity a #pred :: Identity a -> Identity a #toEnum :: Int -> Identity a #fromEnum :: Identity a -> Int #enumFrom :: Identity a -> [Identity a] #enumFromThen :: Identity a -> Identity a -> [Identity a] #enumFromTo :: Identity a -> Identity a -> [Identity a] #enumFromThenTo :: Identity a -> Identity a -> Identity a -> [Identity a] # KnownNat n => Enum (BitVector n) # The functions: enumFrom, enumFromThen, enumFromTo, and enumFromThenTo, are not synthesisable. Instance detailsDefined in Clash.Sized.Internal.BitVector Methodssucc :: BitVector n -> BitVector n #pred :: BitVector n -> BitVector n #toEnum :: Int -> BitVector n #fromEnum :: BitVector n -> Int #enumFrom :: BitVector n -> [BitVector n] #enumFromThen :: BitVector n -> BitVector n -> [BitVector n] #enumFromTo :: BitVector n -> BitVector n -> [BitVector n] #enumFromThenTo :: BitVector n -> BitVector n -> BitVector n -> [BitVector n] # KnownNat n => Enum (Index n) # The functions: enumFrom, enumFromThen, enumFromTo, and enumFromThenTo, are not synthesisable. Instance detailsDefined in Clash.Sized.Internal.Index Methodssucc :: Index n -> Index n #pred :: Index n -> Index n #toEnum :: Int -> Index n #fromEnum :: Index n -> Int #enumFrom :: Index n -> [Index n] #enumFromThen :: Index n -> Index n -> [Index n] #enumFromTo :: Index n -> Index n -> [Index n] #enumFromThenTo :: Index n -> Index n -> Index n -> [Index n] # Enum a => Enum (Bounds a) Instance detailsDefined in Test.QuickCheck.Arbitrary Methodssucc :: Bounds a -> Bounds a #pred :: Bounds a -> Bounds a #toEnum :: Int -> Bounds a #fromEnum :: Bounds a -> Int #enumFrom :: Bounds a -> [Bounds a] #enumFromThen :: Bounds a -> Bounds a -> [Bounds a] #enumFromTo :: Bounds a -> Bounds a -> [Bounds a] #enumFromThenTo :: Bounds a -> Bounds a -> Bounds a -> [Bounds a] # KnownNat n => Enum (Unsigned n) # The functions: enumFrom, enumFromThen, enumFromTo, and enumFromThenTo, are not synthesisable. Instance detailsDefined in Clash.Sized.Internal.Unsigned Methodssucc :: Unsigned n -> Unsigned n #pred :: Unsigned n -> Unsigned n #toEnum :: Int -> Unsigned n #fromEnum :: Unsigned n -> Int #enumFrom :: Unsigned n -> [Unsigned n] #enumFromThen :: Unsigned n -> Unsigned n -> [Unsigned n] #enumFromTo :: Unsigned n -> Unsigned n -> [Unsigned n] #enumFromThenTo :: Unsigned n -> Unsigned n -> Unsigned n -> [Unsigned n] # KnownNat n => Enum (Signed n) # The functions: enumFrom, enumFromThen, enumFromTo, and enumFromThenTo, are not synthesisable. Instance detailsDefined in Clash.Sized.Internal.Signed Methodssucc :: Signed n -> Signed n #pred :: Signed n -> Signed n #toEnum :: Int -> Signed n #fromEnum :: Signed n -> Int #enumFrom :: Signed n -> [Signed n] #enumFromThen :: Signed n -> Signed n -> [Signed n] #enumFromTo :: Signed n -> Signed n -> [Signed n] #enumFromThenTo :: Signed n -> Signed n -> Signed n -> [Signed n] # a => Enum (Dict a) Instance detailsDefined in Data.Constraint Methodssucc :: Dict a -> Dict a #pred :: Dict a -> Dict a #toEnum :: Int -> Dict a #fromEnum :: Dict a -> Int #enumFrom :: Dict a -> [Dict a] #enumFromThen :: Dict a -> Dict a -> [Dict a] #enumFromTo :: Dict a -> Dict a -> [Dict a] #enumFromThenTo :: Dict a -> Dict a -> Dict a -> [Dict a] # (Enum a) :=> (Enum (Identity a)) Instance detailsDefined in Data.Constraint Methodsins :: Enum a :- Enum (Identity a) (Enum a) :=> (Enum (Const a b)) Instance detailsDefined in Data.Constraint Methodsins :: Enum a :- Enum (Const a b) (Integral a) :=> (Enum (Ratio a)) Instance detailsDefined in Data.Constraint Methodsins :: Integral a :- Enum (Ratio a) Enum (Proxy s) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodssucc :: Proxy s -> Proxy s #pred :: Proxy s -> Proxy s #toEnum :: Int -> Proxy s #fromEnum :: Proxy s -> Int #enumFrom :: Proxy s -> [Proxy s] #enumFromThen :: Proxy s -> Proxy s -> [Proxy s] #enumFromTo :: Proxy s -> Proxy s -> [Proxy s] #enumFromThenTo :: Proxy s -> Proxy s -> Proxy s -> [Proxy s] # Class (Real a, Enum a) (Integral a) Instance detailsDefined in Data.Constraint Methodscls :: Integral a :- (Real a, Enum a) Enum a => Enum (Const a b) Instance detailsDefined in Data.Functor.Const Methodssucc :: Const a b -> Const a b #pred :: Const a b -> Const a b #toEnum :: Int -> Const a b #fromEnum :: Const a b -> Int #enumFrom :: Const a b -> [Const a b] #enumFromThen :: Const a b -> Const a b -> [Const a b] #enumFromTo :: Const a b -> Const a b -> [Const a b] #enumFromThenTo :: Const a b -> Const a b -> Const a b -> [Const a b] # Enum (f a) => Enum (Alt f a) Instance detailsDefined in Data.Semigroup.Internal Methodssucc :: Alt f a -> Alt f a #pred :: Alt f a -> Alt f a #toEnum :: Int -> Alt f a #fromEnum :: Alt f a -> Int #enumFrom :: Alt f a -> [Alt f a] #enumFromThen :: Alt f a -> Alt f a -> [Alt f a] #enumFromTo :: Alt f a -> Alt f a -> [Alt f a] #enumFromThenTo :: Alt f a -> Alt f a -> Alt f a -> [Alt f a] # a ~ b => Enum (a :~: b) Since: base-4.7.0.0 Instance detailsDefined in Data.Type.Equality Methodssucc :: (a :~: b) -> a :~: b #pred :: (a :~: b) -> a :~: b #toEnum :: Int -> a :~: b #fromEnum :: (a :~: b) -> Int #enumFrom :: (a :~: b) -> [a :~: b] #enumFromThen :: (a :~: b) -> (a :~: b) -> [a :~: b] #enumFromTo :: (a :~: b) -> (a :~: b) -> [a :~: b] #enumFromThenTo :: (a :~: b) -> (a :~: b) -> (a :~: b) -> [a :~: b] # Enum a => Enum (Tagged s a) Instance detailsDefined in Data.Tagged Methodssucc :: Tagged s a -> Tagged s a #pred :: Tagged s a -> Tagged s a #toEnum :: Int -> Tagged s a #fromEnum :: Tagged s a -> Int #enumFrom :: Tagged s a -> [Tagged s a] #enumFromThen :: Tagged s a -> Tagged s a -> [Tagged s a] #enumFromTo :: Tagged s a -> Tagged s a -> [Tagged s a] #enumFromThenTo :: Tagged s a -> Tagged s a -> Tagged s a -> [Tagged s a] # Enum (rep (int + frac)) => Enum (Fixed rep int frac) # Instance detailsDefined in Clash.Sized.Fixed Methodssucc :: Fixed rep int frac -> Fixed rep int frac #pred :: Fixed rep int frac -> Fixed rep int frac #toEnum :: Int -> Fixed rep int frac #fromEnum :: Fixed rep int frac -> Int #enumFrom :: Fixed rep int frac -> [Fixed rep int frac] #enumFromThen :: Fixed rep int frac -> Fixed rep int frac -> [Fixed rep int frac] #enumFromTo :: Fixed rep int frac -> Fixed rep int frac -> [Fixed rep int frac] #enumFromThenTo :: Fixed rep int frac -> Fixed rep int frac -> Fixed rep int frac -> [Fixed rep int frac] # a ~~ b => Enum (a :~~: b) Since: base-4.10.0.0 Instance detailsDefined in Data.Type.Equality Methodssucc :: (a :~~: b) -> a :~~: b #pred :: (a :~~: b) -> a :~~: b #toEnum :: Int -> a :~~: b #fromEnum :: (a :~~: b) -> Int #enumFrom :: (a :~~: b) -> [a :~~: b] #enumFromThen :: (a :~~: b) -> (a :~~: b) -> [a :~~: b] #enumFromTo :: (a :~~: b) -> (a :~~: b) -> [a :~~: b] #enumFromThenTo :: (a :~~: b) -> (a :~~: b) -> (a :~~: b) -> [a :~~: b] #

class Eq a where #

The Eq class defines equality (==) and inequality (/=). All the basic datatypes exported by the Prelude are instances of Eq, and Eq may be derived for any datatype whose constituents are also instances of Eq.

Minimal complete definition: either == or /=.

Minimal complete definition

Methods

(==) :: a -> a -> Bool infix 4 #

(/=) :: a -> a -> Bool infix 4 #

Instances

class Fractional a => Floating a where #

Trigonometric and hyperbolic functions and related functions.

Minimal complete definition

Methods

pi :: a #

exp :: a -> a #

log :: a -> a #

sqrt :: a -> a #

(**) :: a -> a -> a infixr 8 #

logBase :: a -> a -> a #

sin :: a -> a #

cos :: a -> a #

tan :: a -> a #

asin :: a -> a #

acos :: a -> a #

atan :: a -> a #

sinh :: a -> a #

cosh :: a -> a #

tanh :: a -> a #

asinh :: a -> a #

acosh :: a -> a #

atanh :: a -> a #

Instances
 Since: base-2.1 Instance detailsDefined in GHC.Float Methodsexp :: Double -> Double #log :: Double -> Double #(**) :: Double -> Double -> Double #sin :: Double -> Double #cos :: Double -> Double #tan :: Double -> Double # Since: base-2.1 Instance detailsDefined in GHC.Float Methodspi :: Float #exp :: Float -> Float #log :: Float -> Float #sqrt :: Float -> Float #(**) :: Float -> Float -> Float #logBase :: Float -> Float -> Float #sin :: Float -> Float #cos :: Float -> Float #tan :: Float -> Float #asin :: Float -> Float #acos :: Float -> Float #atan :: Float -> Float #sinh :: Float -> Float #cosh :: Float -> Float #tanh :: Float -> Float #asinh :: Float -> Float #acosh :: Float -> Float #atanh :: Float -> Float #log1p :: Float -> Float #expm1 :: Float -> Float # Instance detailsDefined in Foreign.C.Types Methodsexp :: CFloat -> CFloat #log :: CFloat -> CFloat #(**) :: CFloat -> CFloat -> CFloat #sin :: CFloat -> CFloat #cos :: CFloat -> CFloat #tan :: CFloat -> CFloat # Instance detailsDefined in Foreign.C.Types Methods Floating Half Instance detailsDefined in Numeric.Half Methodspi :: Half #exp :: Half -> Half #log :: Half -> Half #sqrt :: Half -> Half #(**) :: Half -> Half -> Half #logBase :: Half -> Half -> Half #sin :: Half -> Half #cos :: Half -> Half #tan :: Half -> Half #asin :: Half -> Half #acos :: Half -> Half #atan :: Half -> Half #sinh :: Half -> Half #cosh :: Half -> Half #tanh :: Half -> Half #asinh :: Half -> Half #acosh :: Half -> Half #atanh :: Half -> Half #log1p :: Half -> Half #expm1 :: Half -> Half #log1pexp :: Half -> Half #log1mexp :: Half -> Half # () :=> (Floating Double) Instance detailsDefined in Data.Constraint Methodsins :: () :- Floating Double () :=> (Floating Float) Instance detailsDefined in Data.Constraint Methodsins :: () :- Floating Float RealFloat a => Floating (Complex a) Since: base-2.1 Instance detailsDefined in Data.Complex Methodspi :: Complex a #exp :: Complex a -> Complex a #log :: Complex a -> Complex a #sqrt :: Complex a -> Complex a #(**) :: Complex a -> Complex a -> Complex a #logBase :: Complex a -> Complex a -> Complex a #sin :: Complex a -> Complex a #cos :: Complex a -> Complex a #tan :: Complex a -> Complex a #asin :: Complex a -> Complex a #acos :: Complex a -> Complex a #atan :: Complex a -> Complex a #sinh :: Complex a -> Complex a #cosh :: Complex a -> Complex a #tanh :: Complex a -> Complex a #asinh :: Complex a -> Complex a #acosh :: Complex a -> Complex a #atanh :: Complex a -> Complex a #log1p :: Complex a -> Complex a #expm1 :: Complex a -> Complex a #log1pexp :: Complex a -> Complex a #log1mexp :: Complex a -> Complex a # Floating a => Floating (Identity a) Instance detailsDefined in Data.Functor.Identity Methodspi :: Identity a #exp :: Identity a -> Identity a #log :: Identity a -> Identity a #sqrt :: Identity a -> Identity a #(**) :: Identity a -> Identity a -> Identity a #logBase :: Identity a -> Identity a -> Identity a #sin :: Identity a -> Identity a #cos :: Identity a -> Identity a #tan :: Identity a -> Identity a #asin :: Identity a -> Identity a #acos :: Identity a -> Identity a #atan :: Identity a -> Identity a #sinh :: Identity a -> Identity a #cosh :: Identity a -> Identity a #tanh :: Identity a -> Identity a #asinh :: Identity a -> Identity a #acosh :: Identity a -> Identity a #atanh :: Identity a -> Identity a #log1p :: Identity a -> Identity a #expm1 :: Identity a -> Identity a #log1pexp :: Identity a -> Identity a #log1mexp :: Identity a -> Identity a # (Floating a) :=> (Floating (Identity a)) Instance detailsDefined in Data.Constraint Methodsins :: Floating a :- Floating (Identity a) (Floating a) :=> (Floating (Const a b)) Instance detailsDefined in Data.Constraint Methodsins :: Floating a :- Floating (Const a b) (RealFloat a) :=> (Floating (Complex a)) Instance detailsDefined in Data.Constraint Methodsins :: RealFloat a :- Floating (Complex a) Class (Fractional a) (Floating a) Instance detailsDefined in Data.Constraint Methodscls :: Floating a :- Fractional a Floating a => Floating (Op a b) Instance detailsDefined in Data.Functor.Contravariant Methodspi :: Op a b #exp :: Op a b -> Op a b #log :: Op a b -> Op a b #sqrt :: Op a b -> Op a b #(**) :: Op a b -> Op a b -> Op a b #logBase :: Op a b -> Op a b -> Op a b #sin :: Op a b -> Op a b #cos :: Op a b -> Op a b #tan :: Op a b -> Op a b #asin :: Op a b -> Op a b #acos :: Op a b -> Op a b #atan :: Op a b -> Op a b #sinh :: Op a b -> Op a b #cosh :: Op a b -> Op a b #tanh :: Op a b -> Op a b #asinh :: Op a b -> Op a b #acosh :: Op a b -> Op a b #atanh :: Op a b -> Op a b #log1p :: Op a b -> Op a b #expm1 :: Op a b -> Op a b #log1pexp :: Op a b -> Op a b #log1mexp :: Op a b -> Op a b # Class (RealFrac a, Floating a) (RealFloat a) Instance detailsDefined in Data.Constraint Methodscls :: RealFloat a :- (RealFrac a, Floating a) Floating a => Floating (Const a b) Instance detailsDefined in Data.Functor.Const Methodspi :: Const a b #exp :: Const a b -> Const a b #log :: Const a b -> Const a b #sqrt :: Const a b -> Const a b #(**) :: Const a b -> Const a b -> Const a b #logBase :: Const a b -> Const a b -> Const a b #sin :: Const a b -> Const a b #cos :: Const a b -> Const a b #tan :: Const a b -> Const a b #asin :: Const a b -> Const a b #acos :: Const a b -> Const a b #atan :: Const a b -> Const a b #sinh :: Const a b -> Const a b #cosh :: Const a b -> Const a b #tanh :: Const a b -> Const a b #asinh :: Const a b -> Const a b #acosh :: Const a b -> Const a b #atanh :: Const a b -> Const a b #log1p :: Const a b -> Const a b #expm1 :: Const a b -> Const a b #log1pexp :: Const a b -> Const a b #log1mexp :: Const a b -> Const a b # Floating a => Floating (Tagged s a) Instance detailsDefined in Data.Tagged Methodspi :: Tagged s a #exp :: Tagged s a -> Tagged s a #log :: Tagged s a -> Tagged s a #sqrt :: Tagged s a -> Tagged s a #(**) :: Tagged s a -> Tagged s a -> Tagged s a #logBase :: Tagged s a -> Tagged s a -> Tagged s a #sin :: Tagged s a -> Tagged s a #cos :: Tagged s a -> Tagged s a #tan :: Tagged s a -> Tagged s a #asin :: Tagged s a -> Tagged s a #acos :: Tagged s a -> Tagged s a #atan :: Tagged s a -> Tagged s a #sinh :: Tagged s a -> Tagged s a #cosh :: Tagged s a -> Tagged s a #tanh :: Tagged s a -> Tagged s a #asinh :: Tagged s a -> Tagged s a #acosh :: Tagged s a -> Tagged s a #atanh :: Tagged s a -> Tagged s a #log1p :: Tagged s a -> Tagged s a #expm1 :: Tagged s a -> Tagged s a #log1pexp :: Tagged s a -> Tagged s a #log1mexp :: Tagged s a -> Tagged s a #

class Num a => Fractional a where #

Fractional numbers, supporting real division.

Minimal complete definition

fromRational, (recip | (/))

Methods

(/) :: a -> a -> a infixl 7 #

fractional division

recip :: a -> a #

reciprocal fraction

fromRational :: Rational -> a #

Conversion from a Rational (that is Ratio Integer). A floating literal stands for an application of fromRational to a value of type Rational, so such literals have type (Fractional a) => a.

Instances
 Instance detailsDefined in Foreign.C.Types Methods(/) :: CFloat -> CFloat -> CFloat # Instance detailsDefined in Foreign.C.Types Methods Fractional Half Instance detailsDefined in Numeric.Half Methods(/) :: Half -> Half -> Half #recip :: Half -> Half #fromRational :: Rational -> Half # () :=> (Fractional Double) Instance detailsDefined in Data.Constraint Methodsins :: () :- Fractional Double () :=> (Fractional Float) Instance detailsDefined in Data.Constraint Methodsins :: () :- Fractional Float Integral a => Fractional (Ratio a) Since: base-2.0.1 Instance detailsDefined in GHC.Real Methods(/) :: Ratio a -> Ratio a -> Ratio a #recip :: Ratio a -> Ratio a # RealFloat a => Fractional (Complex a) Since: base-2.1 Instance detailsDefined in Data.Complex Methods(/) :: Complex a -> Complex a -> Complex a #recip :: Complex a -> Complex a # HasResolution a => Fractional (Fixed a) Since: base-2.1 Instance detailsDefined in Data.Fixed Methods(/) :: Fixed a -> Fixed a -> Fixed a #recip :: Fixed a -> Fixed a # Fractional a => Fractional (Identity a) Instance detailsDefined in Data.Functor.Identity Methods(/) :: Identity a -> Identity a -> Identity a #recip :: Identity a -> Identity a # (Fractional a) :=> (Fractional (Identity a)) Instance detailsDefined in Data.Constraint Methodsins :: Fractional a :- Fractional (Identity a) (Fractional a) :=> (Fractional (Const a b)) Instance detailsDefined in Data.Constraint Methodsins :: Fractional a :- Fractional (Const a b) (Integral a) :=> (Fractional (Ratio a)) Instance detailsDefined in Data.Constraint Methodsins :: Integral a :- Fractional (Ratio a) (RealFloat a) :=> (Fractional (Complex a)) Instance detailsDefined in Data.Constraint Methodsins :: RealFloat a :- Fractional (Complex a) Class (Fractional a) (Floating a) Instance detailsDefined in Data.Constraint Methodscls :: Floating a :- Fractional a Class (Num a) (Fractional a) Instance detailsDefined in Data.Constraint Methodscls :: Fractional a :- Num a Fractional a => Fractional (Op a b) Instance detailsDefined in Data.Functor.Contravariant Methods(/) :: Op a b -> Op a b -> Op a b #recip :: Op a b -> Op a b #fromRational :: Rational -> Op a b # Fractional a => Fractional (Signal domain a) # Instance detailsDefined in Clash.Signal.Internal Methods(/) :: Signal domain a -> Signal domain a -> Signal domain a #recip :: Signal domain a -> Signal domain a #fromRational :: Rational -> Signal domain a # Class (Real a, Fractional a) (RealFrac a) Instance detailsDefined in Data.Constraint Methodscls :: RealFrac a :- (Real a, Fractional a) Fractional a => Fractional (Const a b) Instance detailsDefined in Data.Functor.Const Methods(/) :: Const a b -> Const a b -> Const a b #recip :: Const a b -> Const a b #fromRational :: Rational -> Const a b # Fractional a => Fractional (Tagged s a) Instance detailsDefined in Data.Tagged Methods(/) :: Tagged s a -> Tagged s a -> Tagged s a #recip :: Tagged s a -> Tagged s a #fromRational :: Rational -> Tagged s a # FracFixedC rep int frac => Fractional (Fixed rep int frac) # The operators of this instance saturate on overflow, and use truncation as the rounding method.When used in a polymorphic setting, use the following Constraint synonyms for less verbose type signatures:FracFixedC frac rep size for: Fixed frac rep sizeFracSFixedC int frac for: SFixed int fracFracUFixedC int frac for: UFixed int frac Instance detailsDefined in Clash.Sized.Fixed Methods(/) :: Fixed rep int frac -> Fixed rep int frac -> Fixed rep int frac #recip :: Fixed rep int frac -> Fixed rep int frac #fromRational :: Rational -> Fixed rep int frac # Fractional a => Fractional (DSignal domain delay a) # Instance detailsDefined in Clash.Explicit.Signal.Delayed Methods(/) :: DSignal domain delay a -> DSignal domain delay a -> DSignal domain delay a #recip :: DSignal domain delay a -> DSignal domain delay a #fromRational :: Rational -> DSignal domain delay a #

class (Real a, Enum a) => Integral a where #

Integral numbers, supporting integer division.

Minimal complete definition

Methods

quot :: a -> a -> a infixl 7 #

integer division truncated toward zero

rem :: a -> a -> a