clash-lib-0.2.0.1: CAES Language for Synchronous Hardware - As a Library

Safe HaskellNone

CLaSH.Util

Description

Assortment of utility function used in the CLaSH library

Synopsis

Documentation

class MonadUnique m whereSource

A class that can generate unique numbers

Methods

getUniqueM :: m IntSource

Get a new unique

Instances

Monad m => MonadUnique (R m) 
Monad m => MonadUnique (RewriteMonad m) 
Monad m => MonadUnique (StateT Int m) 

curLoc :: Q ExpSource

Create a TH expression that returns the a formatted string containing the name of the module curLoc is spliced into, and the line where it was spliced.

makeCachedSource

Arguments

:: (MonadState s m, Hashable k, Eq k) 
=> k

The key the action is associated with

-> Lens' s (HashMap k v)

The Lens to the HashMap that is the cache

-> m v

The action to cache

-> m v 

Cache the result of a monadic action

makeCachedT3Source

Arguments

:: (MonadTrans t2, MonadTrans t1, MonadTrans t, Eq k, Hashable k, MonadState s m, Monad (t2 m), Monad (t1 (t2 m)), Monad (t (t1 (t2 m)))) 
=> k

The key the action is associated with

-> Lens' s (HashMap k v)

The Lens to the HashMap that is the cache

-> t (t1 (t2 m)) v

The action to cache

-> t (t1 (t2 m)) v 

Cache the result of a monadic action in a State 3 transformer layers down

makeCachedT3' :: (MonadTrans t2, MonadTrans t1, MonadTrans t, Eq k, Hashable k, MonadState s m, Monad (t2 m), Monad (t1 (t2 m)), Monad (t (t1 (t2 m)))) => k -> Lens' s (HashMap k v) -> t (t1 (t2 m)) v -> t (t1 (t2 m)) vSource

Spine-strict cache variant of mkCachedT3

liftStateSource

Arguments

:: MonadState s m 
=> Lens' s s'

Lens to the State in the higher-layer monad

-> State s' a

The State-action to perform

-> m a 

Run a State-action using the State that is stored in a higher-layer Monad

firstM :: Functor f => (a -> f c) -> (a, b) -> f (c, b)Source

Functorial version of first

secondM :: Functor f => (b -> f c) -> (a, b) -> f (a, c)Source

Functorial version of second

traceIf :: Bool -> String -> a -> aSource

Performs trace when first argument evaluates to True

partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])Source

Monadic version of partition

mapAccumLM :: Monad m => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, [y])Source

Monadic version of mapAccumL

dot :: (c -> d) -> (a -> b -> c) -> a -> b -> dSource

Composition of a unary function with a binary function

ifThenElse :: (a -> Bool) -> (a -> b) -> (a -> b) -> a -> bSource

if-then-else as a function on an argument

(<:>) :: Applicative f => f a -> f [a] -> f [a]Source

Applicative version of 'GHC.Types.(:)'

indexMaybe :: [a] -> Int -> Maybe aSource

Safe indexing, returns a Nothing if the index does not exist

indexNote :: String -> [a] -> Int -> aSource

Unsafe indexing, return a custom error message when indexing fails

splitAtList :: [b] -> [a] -> ([a], [a])Source

Split the second list at the length of the first list

makeLenses :: Name -> Q [Dec]

Build lenses (and traversals) with a sensible default configuration.

 makeLenses = makeLensesWith lensRules