rewire-user-2.8
Safe HaskellNone
LanguageHaskell2010

RWC.Primitives

Synopsis

Documentation

type ReacT = ReacT Source #

type Vec = Vector Source #

type Finite = Finite Source #

data Proxy (n :: Nat) Source #

Constructors

Proxy 

rwPrimAdd :: forall (n :: Nat). KnownNat n => Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Add (wrapping mod 2^n).

rwPrimAnd :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Bitwise and.

rwPrimBind :: Monad m => m a -> (a -> m b) -> m b Source #

rwPrimBitIndex :: forall (n :: Nat). Vec n Bool -> Finite n -> Bool Source #

bitIndex a i == bitSlice a i i. The Finite argument must be known/literal (after inlining).

rwPrimBitSlice :: forall (m :: Nat) (n :: Nat). KnownNat m => Vec n Bool -> Finite n -> Finite n -> Vec m Bool Source #

bitSlice a j i returns bits j (most significant) to i (least significant) from a (j >= i). Bits are numbered with the least significant bit at 0 (Verilog convention); the head of the Vec is the most significant bit. The Finite arguments must be known/literals (after inlining).

rwPrimBits :: Integer -> Vec 128 Bool Source #

Interpret an Integer as a bit vector.

rwPrimCryptol Source #

Arguments

:: String

Cryptol module file.

-> String

Function name.

-> a

Haskell definition to use when running under GHC.

-> a 

The String arguments must be literals (after inlining).

rwPrimDiv :: forall (n :: Nat). KnownNat n => Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Unsigned division. Division by zero yields all-ones (2^n - 1), following the SMT-LIB convention implemented by the compiled RTL and the interpreter.

rwPrimEq :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Bool Source #

Equal.

rwPrimError :: String -> a Source #

rwPrimExtern Source #

Arguments

:: [(String, Integer)]

Module parameters (name and integer literal value).

-> String

Clock signal name or empty for no clock.

-> String

Reset signal name or empty for no reset.

-> [(String, Integer)]

Module inputs (name and integer literal bitwidth).

-> [(String, Integer)]

Module outputs (name and integer literal bitwidth).

-> String

Module name.

-> a

Haskell definition to use when interpreting.

-> String

Reserved: an instance-name hint; currently ignored by the compiler.

-> a 

The String and list arguments must be literals (after inlining).

rwPrimExtrude :: forall (m :: Type -> Type) i o s a. Monad m => ReacT i o (StateT s m) a -> s -> ReacT i o m a Source #

rwPrimGet :: forall (m :: Type -> Type) s. Monad m => StateT s m s Source #

rwPrimGt :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Bool Source #

Greater-than.

rwPrimGtEq :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Bool Source #

Greater-than or equal.

rwPrimLAnd :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Bool Source #

Logical and.

rwPrimLNot :: forall (n :: Nat). Vec n Bool -> Bool Source #

Logical not.

rwPrimLOr :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Bool Source #

Logical or.

rwPrimLShift :: forall (n :: Nat). KnownNat n => Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Shift left.

rwPrimLift :: (MonadTrans t, Monad m) => m a -> t m a Source #

rwPrimLt :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Bool Source #

Less-than.

rwPrimLtEq :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Bool Source #

Less-than or equal.

rwPrimMSBit :: forall (n :: Natural). Vec (1 + n) Bool -> Bool Source #

Most significant bit.

rwPrimMod :: forall (n :: Nat). KnownNat n => Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Unsigned modulus. A zero divisor yields the dividend, following the SMT-LIB convention implemented by the compiled RTL and the interpreter.

rwPrimMul :: forall (n :: Nat). KnownNat n => Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Multiply (wrapping mod 2^n).

rwPrimNatVal :: forall (n :: Nat). KnownNat n => Proxy n -> Integer Source #

Produce integer associated with type-level natural.

rwPrimNot :: forall (n :: Nat). Vec n Bool -> Vec n Bool Source #

Bitwise not.

rwPrimOr :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Bitwise or.

rwPrimPow :: forall (n :: Nat). KnownNat n => Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Exponentiation.

rwPrimPut :: forall (m :: Type -> Type) s. Monad m => s -> StateT s m () Source #

rwPrimRAnd :: forall (n :: Nat). Vec n Bool -> Bool Source #

Reduction and.

rwPrimRNAnd :: forall (n :: Natural). Vec (1 + n) Bool -> Bool Source #

Reduction nand (NOT of the and-reduction, following the Verilog ~& operator).

rwPrimRNor :: forall (n :: Natural). Vec (1 + n) Bool -> Bool Source #

Reduction nor (NOT of the or-reduction, following the Verilog ~| operator).

rwPrimROr :: forall (n :: Nat). Vec n Bool -> Bool Source #

Reduction or.

rwPrimRShift :: forall (n :: Nat). KnownNat n => Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Shift right.

rwPrimRShiftArith :: forall (n :: Nat). KnownNat n => Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Shift right, sign-extend.

rwPrimRXNor :: forall (n :: Natural). Vec (1 + n) Bool -> Bool Source #

Reduction xnor (NOT of the xor-reduction, following the Verilog ~^ operator).

rwPrimRXOr :: forall (n :: Natural). Vec (1 + n) Bool -> Bool Source #

Reduction xor.

rwPrimResize :: forall (m :: Nat) (n :: Nat). KnownNat m => Vec n Bool -> Vec m Bool Source #

Truncates or zero-pads most significant bits.

rwPrimReturn :: Monad m => a -> m a Source #

rwPrimSignal :: forall (m :: Type -> Type) o i. Monad m => o -> ReacT i o m i Source #

rwPrimSub :: forall (n :: Nat). KnownNat n => Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Subtract (wrapping mod 2^n).

rwPrimFinite :: forall (n :: Nat). KnownNat n => Integer -> Finite n Source #

Convert an Integer into a Finite n, throws an error if negative or >= n.

rwPrimFiniteMinBound :: forall (n :: Nat). KnownNat n => Finite n Source #

rwPrimFiniteMaxBound :: forall (n :: Nat). KnownNat n => Finite n Source #

rwPrimToFinite :: forall (n :: Nat) (m :: Nat). KnownNat n => Vec m Bool -> Finite n Source #

rwPrimToFiniteMod :: forall (m :: Nat) (n :: Nat). KnownNat n => Vec m Bool -> Finite n Source #

rwPrimFromFinite :: forall (m :: Nat) (n :: Nat). KnownNat m => Finite n -> Vec m Bool Source #

rwPrimVecConcat :: forall (n :: Nat) a (m :: Nat). Vec n a -> Vec m a -> Vec (n + m) a Source #

Concatenate vectors.

rwPrimVecFromList :: forall (n :: Nat) a. KnownNat n => [a] -> Vec n a Source #

Turns a List literal into a Vec with fixed length. I.e.,

[x, y, z] :: Vec 3 a

rwPrimVecIndex :: forall (n :: Nat) a. Vec n a -> Finite n -> a Source #

rwPrimVecIndexProxy :: forall (n :: Nat) (m :: Natural) a. KnownNat n => Vec ((n + m) + 1) a -> Proxy n -> a Source #

rwPrimVecMap :: forall a b (n :: Nat). (a -> b) -> Vec n a -> Vec n b Source #

rwPrimVecGenerate :: forall (n :: Nat) a. KnownNat n => (Finite n -> a) -> Vec n a Source #

rwPrimVecRSlice :: forall (i :: Nat) (n :: Nat) (m :: Natural) a. (KnownNat i, KnownNat n) => Proxy i -> Vec ((i + n) + m) a -> Vec n a Source #

Slice indexed from the end of the Vec.

rwPrimVecReplicate :: forall (n :: Nat) a. KnownNat n => a -> Vec n a Source #

rwPrimVecReverse :: forall (n :: Nat) a. Vec n a -> Vec n a Source #

rwPrimVecSlice :: forall (i :: Nat) (n :: Nat) (m :: Natural) a. (KnownNat i, KnownNat n) => Proxy i -> Vec ((i + n) + m) a -> Vec n a Source #

rwPrimXNor :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Bitwise exclusive nor.

rwPrimXOr :: forall (n :: Nat). Vec n Bool -> Vec n Bool -> Vec n Bool Source #

Bitwise exclusive or.

toIntegerV :: forall (n :: Nat). Vec n Bool -> Integer Source #

The unsigned value of a bit vector, as an Integer. Not a primitive: GHC-only simulation support backing ReWire.Bits.toInteger (Integer is a compile-time-literal-only type in the compiled fragment). It lives here because neither front end translates this module's bodies or chases its imports.

type family (a :: Natural) + (b :: Natural) :: Natural where ... infixl 6 #

Addition of type-level naturals.

Since: base-4.7.0.0

class Applicative m => Monad (m :: Type -> Type) #

The Monad class defines the basic operations over a monad, a concept from a branch of mathematics known as category theory. From the perspective of a Haskell programmer, however, it is best to think of a monad as an abstract datatype of actions. Haskell's do expressions provide a convenient syntax for writing monadic expressions.

Instances of Monad should satisfy the following:

Left identity
return a >>= k = k a
Right identity
m >>= return = m
Associativity
m >>= (\x -> k x >>= h) = (m >>= k) >>= h

Furthermore, the Monad and Applicative operations should relate as follows:

The above laws imply:

and that pure and (<*>) satisfy the applicative functor laws.

The instances of Monad for List, Maybe and IO defined in the Prelude satisfy these laws.

Minimal complete definition

(>>=)

Instances

Instances details
Monad Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

(>>=) :: Complex a -> (a -> Complex b) -> Complex b #

(>>) :: Complex a -> Complex b -> Complex b #

return :: a -> Complex a #

Monad First

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

(>>=) :: First a -> (a -> First b) -> First b #

(>>) :: First a -> First b -> First b #

return :: a -> First a #

Monad Last

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

(>>=) :: Last a -> (a -> Last b) -> Last b #

(>>) :: Last a -> Last b -> Last b #

return :: a -> Last a #

Monad Max

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

(>>=) :: Max a -> (a -> Max b) -> Max b #

(>>) :: Max a -> Max b -> Max b #

return :: a -> Max a #

Monad Min

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

(>>=) :: Min a -> (a -> Min b) -> Min b #

(>>) :: Min a -> Min b -> Min b #

return :: a -> Min a #

Monad NonEmpty

Since: base-4.9.0.0

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: NonEmpty a -> (a -> NonEmpty b) -> NonEmpty b #

(>>) :: NonEmpty a -> NonEmpty b -> NonEmpty b #

return :: a -> NonEmpty a #

Monad Identity

Since: base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Methods

(>>=) :: Identity a -> (a -> Identity b) -> Identity b #

(>>) :: Identity a -> Identity b -> Identity b #

return :: a -> Identity a #

Monad IO

Since: base-2.1

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: IO a -> (a -> IO b) -> IO b #

(>>) :: IO a -> IO b -> IO b #

return :: a -> IO a #

Monad Vector 
Instance details

Defined in Data.Vector

Methods

(>>=) :: Vector a -> (a -> Vector b) -> Vector b #

(>>) :: Vector a -> Vector b -> Vector b #

return :: a -> Vector a #

Monad Id 
Instance details

Defined in Data.Vector.Fusion.Util

Methods

(>>=) :: Id a -> (a -> Id b) -> Id b #

(>>) :: Id a -> Id b -> Id b #

return :: a -> Id a #

Monad Vector 
Instance details

Defined in Data.Vector.Strict

Methods

(>>=) :: Vector a -> (a -> Vector b) -> Vector b #

(>>) :: Vector a -> Vector b -> Vector b #

return :: a -> Vector a #

Monad Maybe

Since: base-2.1

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b #

(>>) :: Maybe a -> Maybe b -> Maybe b #

return :: a -> Maybe a #

Monad Solo

Since: base-4.15

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: Solo a -> (a -> Solo b) -> Solo b #

(>>) :: Solo a -> Solo b -> Solo b #

return :: a -> Solo a #

Monad []

Since: base-2.1

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: [a] -> (a -> [b]) -> [b] #

(>>) :: [a] -> [b] -> [b] #

return :: a -> [a] #

Monad m => Monad (WrappedMonad m)

Since: base-4.7.0.0

Instance details

Defined in Control.Applicative

Methods

(>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b #

(>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b #

return :: a -> WrappedMonad m a #

Monad (Either e)

Since: base-4.4.0.0

Instance details

Defined in GHC.Internal.Data.Either

Methods

(>>=) :: Either e a -> (a -> Either e b) -> Either e b #

(>>) :: Either e a -> Either e b -> Either e b #

return :: a -> Either e a #

Monad m => Monad (ResT m) 
Instance details

Defined in Control.Monad.Resumption

Methods

(>>=) :: ResT m a -> (a -> ResT m b) -> ResT m b #

(>>) :: ResT m a -> ResT m b -> ResT m b #

return :: a -> ResT m a #

Monoid a => Monad ((,) a)

Since: base-4.9.0.0

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: (a, a0) -> (a0 -> (a, b)) -> (a, b) #

(>>) :: (a, a0) -> (a, b) -> (a, b) #

return :: a0 -> (a, a0) #

Monad (t m) => Monad (LiftingAccum t m)

Since: mtl-2.3

Instance details

Defined in Control.Monad.Accum

Methods

(>>=) :: LiftingAccum t m a -> (a -> LiftingAccum t m b) -> LiftingAccum t m b #

(>>) :: LiftingAccum t m a -> LiftingAccum t m b -> LiftingAccum t m b #

return :: a -> LiftingAccum t m a #

Monad (t m) => Monad (LiftingSelect t m)

Since: mtl-2.3

Instance details

Defined in Control.Monad.Select

Methods

(>>=) :: LiftingSelect t m a -> (a -> LiftingSelect t m b) -> LiftingSelect t m b #

(>>) :: LiftingSelect t m a -> LiftingSelect t m b -> LiftingSelect t m b #

return :: a -> LiftingSelect t m a #

Monad m => Monad (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

(>>=) :: StateT s m a -> (a -> StateT s m b) -> StateT s m b #

(>>) :: StateT s m a -> StateT s m b -> StateT s m b #

return :: a -> StateT s m a #

KnownNat n => Monad (Vector Vector n) 
Instance details

Defined in Data.Vector.Generic.Sized

Methods

(>>=) :: Vector Vector n a -> (a -> Vector Vector n b) -> Vector Vector n b #

(>>) :: Vector Vector n a -> Vector Vector n b -> Vector Vector n b #

return :: a -> Vector Vector n a #

(Monoid a, Monoid b) => Monad ((,,) a b)

Since: base-4.14.0.0

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: (a, b, a0) -> (a0 -> (a, b, b0)) -> (a, b, b0) #

(>>) :: (a, b, a0) -> (a, b, b0) -> (a, b, b0) #

return :: a0 -> (a, b, a0) #

(Monad f, Monad g) => Monad (Product f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

(>>=) :: Product f g a -> (a -> Product f g b) -> Product f g b #

(>>) :: Product f g a -> Product f g b -> Product f g b #

return :: a -> Product f g a #

Monad m => Monad (ReacT input output m) 
Instance details

Defined in Control.Monad.Resumption.Reactive

Methods

(>>=) :: ReacT input output m a -> (a -> ReacT input output m b) -> ReacT input output m b #

(>>) :: ReacT input output m a -> ReacT input output m b -> ReacT input output m b #

return :: a -> ReacT input output m a #

(Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)

Since: base-4.14.0.0

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: (a, b, c, a0) -> (a0 -> (a, b, c, b0)) -> (a, b, c, b0) #

(>>) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, b0) #

return :: a0 -> (a, b, c, a0) #

Monad ((->) r)

Since: base-2.1

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: (r -> a) -> (a -> r -> b) -> r -> b #

(>>) :: (r -> a) -> (r -> b) -> r -> b #

return :: a -> r -> a #

class (forall (m :: Type -> Type). Monad m => Monad (t m)) => MonadTrans (t :: (Type -> Type) -> Type -> Type) #

The class of monad transformers. For any monad m, the result t m should also be a monad, and lift should be a monad transformation from m to t m, i.e. it should satisfy the following laws:

Since 0.6.0.0 and for GHC 8.6 and later, the requirement that t m be a Monad is enforced by the implication constraint forall m. Monad m => Monad (t m) enabled by the QuantifiedConstraints extension.

Ambiguity error with GHC 9.0 to 9.2.2

Expand

These versions of GHC have a bug (https://gitlab.haskell.org/ghc/ghc/-/issues/20582) which causes constraints like

(MonadTrans t, forall m. Monad m => Monad (t m)) => ...

to be reported as ambiguous. For transformers 0.6 and later, this can be fixed by removing the second constraint, which is implied by the first.

Minimal complete definition

lift

Instances

Instances details
MonadTrans ResT 
Instance details

Defined in Control.Monad.Resumption

Methods

lift :: Monad m => m a -> ResT m a #

MonadTrans (StateT s) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

lift :: Monad m => m a -> StateT s m a #

MonadTrans (ReacT input output) 
Instance details

Defined in Control.Monad.Resumption.Reactive

Methods

lift :: Monad m => m a -> ReacT input output m a #