clash-lib-1.5.0: Clash: a functional hardware description language - As a library
Safe HaskellNone
LanguageHaskell2010

Clash.Unique

Synopsis

Unique

class Uniquable a where Source #

Methods

getUnique :: a -> Unique Source #

setUnique :: a -> Unique -> a Source #

Instances

Instances details
Uniquable Int Source # 
Instance details

Defined in Clash.Unique

Uniquable TyCon Source # 
Instance details

Defined in Clash.Core.TyCon

Uniquable DataCon Source # 
Instance details

Defined in Clash.Core.DataCon

Uniquable (Name a) Source # 
Instance details

Defined in Clash.Core.Name

Uniquable (Var a) Source # 
Instance details

Defined in Clash.Core.Var

Methods

getUnique :: Var a -> Unique Source #

setUnique :: Var a -> Unique -> Var a Source #

UniqMap

data UniqMap a Source #

Map indexed by a Uniquable key

Instances

Instances details
Functor UniqMap Source # 
Instance details

Defined in Clash.Unique

Methods

fmap :: (a -> b) -> UniqMap a -> UniqMap b #

(<$) :: a -> UniqMap b -> UniqMap a #

Foldable UniqMap Source # 
Instance details

Defined in Clash.Unique

Methods

fold :: Monoid m => UniqMap m -> m #

foldMap :: Monoid m => (a -> m) -> UniqMap a -> m #

foldMap' :: Monoid m => (a -> m) -> UniqMap a -> m #

foldr :: (a -> b -> b) -> b -> UniqMap a -> b #

foldr' :: (a -> b -> b) -> b -> UniqMap a -> b #

foldl :: (b -> a -> b) -> b -> UniqMap a -> b #

foldl' :: (b -> a -> b) -> b -> UniqMap a -> b #

foldr1 :: (a -> a -> a) -> UniqMap a -> a #

foldl1 :: (a -> a -> a) -> UniqMap a -> a #

toList :: UniqMap a -> [a] #

null :: UniqMap a -> Bool #

length :: UniqMap a -> Int #

elem :: Eq a => a -> UniqMap a -> Bool #

maximum :: Ord a => UniqMap a -> a #

minimum :: Ord a => UniqMap a -> a #

sum :: Num a => UniqMap a -> a #

product :: Num a => UniqMap a -> a #

Traversable UniqMap Source # 
Instance details

Defined in Clash.Unique

Methods

traverse :: Applicative f => (a -> f b) -> UniqMap a -> f (UniqMap b) #

sequenceA :: Applicative f => UniqMap (f a) -> f (UniqMap a) #

mapM :: Monad m => (a -> m b) -> UniqMap a -> m (UniqMap b) #

sequence :: Monad m => UniqMap (m a) -> m (UniqMap a) #

ClashPretty a => Show (UniqMap a) Source # 
Instance details

Defined in Clash.Unique

Methods

showsPrec :: Int -> UniqMap a -> ShowS #

show :: UniqMap a -> String #

showList :: [UniqMap a] -> ShowS #

Semigroup (UniqMap a) Source # 
Instance details

Defined in Clash.Unique

Methods

(<>) :: UniqMap a -> UniqMap a -> UniqMap a #

sconcat :: NonEmpty (UniqMap a) -> UniqMap a #

stimes :: Integral b => b -> UniqMap a -> UniqMap a #

Monoid (UniqMap a) Source # 
Instance details

Defined in Clash.Unique

Methods

mempty :: UniqMap a #

mappend :: UniqMap a -> UniqMap a -> UniqMap a #

mconcat :: [UniqMap a] -> UniqMap a #

Binary a => Binary (UniqMap a) Source # 
Instance details

Defined in Clash.Unique

Methods

put :: UniqMap a -> Put #

get :: Get (UniqMap a) #

putList :: [UniqMap a] -> Put #

NFData a => NFData (UniqMap a) Source # 
Instance details

Defined in Clash.Unique

Methods

rnf :: UniqMap a -> () #

ClashPretty a => ClashPretty (UniqMap a) Source # 
Instance details

Defined in Clash.Unique

Methods

clashPretty :: UniqMap a -> Doc () Source #

Accessors

Size information

nullUniqMap :: UniqMap a -> Bool Source #

Check whether the map is empty

Indexing

lookupUniqMap :: Uniquable a => a -> UniqMap b -> Maybe b Source #

Look up a value in the map

lookupUniqMap' :: (HasCallStack, Uniquable a) => UniqMap b -> a -> b Source #

Like lookupUniqMap', but errors out when the key is not present

Construction

emptyUniqMap :: UniqMap a Source #

The empty map

unitUniqMap :: Uniquable a => a -> b -> UniqMap b Source #

Map with a single key-value pair

Modification

extendUniqMap :: Uniquable a => a -> b -> UniqMap b -> UniqMap b Source #

Extend the map with a new key-value pair. If the key already exists in the associated value will be overwritten

extendUniqMapWith :: Uniquable a => a -> b -> (b -> b -> b) -> UniqMap b -> UniqMap b Source #

Extend the map with a new key-value pair. If the key already exists in the associated value will be combined with the new value using the function provided

extendListUniqMap :: Uniquable a => UniqMap b -> [(a, b)] -> UniqMap b Source #

Extend the map with a list of key-value pairs. Positions with existing keys will be overwritten with the new values

delUniqMap :: Uniquable a => UniqMap b -> a -> UniqMap b Source #

Remove a key-value pair from the map

delListUniqMap :: Uniquable a => UniqMap b -> [a] -> UniqMap b Source #

Remove a list of key-value pairs from the map

unionUniqMap :: UniqMap a -> UniqMap a -> UniqMap a Source #

A (left-biased) union of two maps

unionUniqMapWith :: (a -> a -> a) -> UniqMap a -> UniqMap a -> UniqMap a Source #

A union of two maps, key-value pairs with the same key will be merged using the given function

differenceUniqMap :: UniqMap a -> UniqMap a -> UniqMap a Source #

Get the difference between two maps

Element-wise operations

Mapping

mapUniqMap :: (a -> b) -> UniqMap a -> UniqMap b Source #

Apply a function to every element in the map

mapMaybeUniqMap :: (a -> Maybe b) -> UniqMap a -> UniqMap b Source #

Apply a function to every element in the map. When the function returns Nothing, the key-value pair will be removed

Working with predicates

Filtering

filterUniqMap :: (b -> Bool) -> UniqMap b -> UniqMap b Source #

Derive a map where all the elements adhere to the predicate

Searching

elemUniqMap :: Uniquable a => a -> UniqMap b -> Bool Source #

Check whether a key is in the map

notElemUniqMap :: Uniquable a => a -> UniqMap b -> Bool Source #

Check whether a key is not in the map

elemUniqMapDirectly :: Unique -> UniqMap b -> Bool Source #

Check whether an element exists in the uniqmap based on a given Unique

Folding

foldrWithUnique :: (Unique -> a -> b -> b) -> b -> UniqMap a -> b Source #

Right-fold over a map using both the key and value

foldlWithUnique' :: (a -> Unique -> b -> a) -> a -> UniqMap b -> a Source #

Strict left-fold over a map using both the key and the value

Conversions

Lists

eltsUniqMap :: UniqMap a -> [a] Source #

Extract the elements of a map into a list

keysUniqMap :: UniqMap a -> [Unique] Source #

Extract the keys of a map into a list

listToUniqMap :: Uniquable a => [(a, b)] -> UniqMap b Source #

Convert a list of key-value pairs to a map

toListUniqMap :: UniqMap a -> [(Unique, a)] Source #

Convert a map to a list of key-value pairs

UniqSet

UniqSet

data UniqSet a Source #

Set of things that have a Unique

Invariant: they keys in the map are the uniques of the values

Instances

Instances details
Foldable UniqSet Source # 
Instance details

Defined in Clash.Unique

Methods

fold :: Monoid m => UniqSet m -> m #

foldMap :: Monoid m => (a -> m) -> UniqSet a -> m #

foldMap' :: Monoid m => (a -> m) -> UniqSet a -> m #

foldr :: (a -> b -> b) -> b -> UniqSet a -> b #

foldr' :: (a -> b -> b) -> b -> UniqSet a -> b #

foldl :: (b -> a -> b) -> b -> UniqSet a -> b #

foldl' :: (b -> a -> b) -> b -> UniqSet a -> b #

foldr1 :: (a -> a -> a) -> UniqSet a -> a #

foldl1 :: (a -> a -> a) -> UniqSet a -> a #

toList :: UniqSet a -> [a] #

null :: UniqSet a -> Bool #

length :: UniqSet a -> Int #

elem :: Eq a => a -> UniqSet a -> Bool #

maximum :: Ord a => UniqSet a -> a #

minimum :: Ord a => UniqSet a -> a #

sum :: Num a => UniqSet a -> a #

product :: Num a => UniqSet a -> a #

Semigroup (UniqSet a) Source # 
Instance details

Defined in Clash.Unique

Methods

(<>) :: UniqSet a -> UniqSet a -> UniqSet a #

sconcat :: NonEmpty (UniqSet a) -> UniqSet a #

stimes :: Integral b => b -> UniqSet a -> UniqSet a #

Monoid (UniqSet a) Source # 
Instance details

Defined in Clash.Unique

Methods

mempty :: UniqSet a #

mappend :: UniqSet a -> UniqSet a -> UniqSet a #

mconcat :: [UniqSet a] -> UniqSet a #

Binary a => Binary (UniqSet a) Source # 
Instance details

Defined in Clash.Unique

Methods

put :: UniqSet a -> Put #

get :: Get (UniqSet a) #

putList :: [UniqSet a] -> Put #

NFData a => NFData (UniqSet a) Source # 
Instance details

Defined in Clash.Unique

Methods

rnf :: UniqSet a -> () #

ClashPretty a => ClashPretty (UniqSet a) Source # 
Instance details

Defined in Clash.Unique

Methods

clashPretty :: UniqSet a -> Doc () Source #

Accessors

Size information

nullUniqSet :: UniqSet a -> Bool Source #

Check whether a set is empty

Indexing

lookupUniqSet :: Uniquable a => a -> UniqSet b -> Maybe b Source #

Look up an element in the set, returns it if it exists

Construction

emptyUniqSet :: UniqSet a Source #

The empty set

unitUniqSet :: Uniquable a => a -> UniqSet a Source #

Set with a single element

Modifications

extendUniqSet :: Uniquable a => UniqSet a -> a -> UniqSet a Source #

Add an element to the set

unionUniqSet :: UniqSet a -> UniqSet a -> UniqSet a Source #

Union two sets

delUniqSetDirectly :: Unique -> UniqSet b -> UniqSet b Source #

Remove an element based on the Unique it contains

Working with predicates

Searching

elemUniqSet :: Uniquable a => a -> UniqSet a -> Bool Source #

Check whether an element exists in the set

notElemUniqSet :: Uniquable a => a -> UniqSet a -> Bool Source #

Check whether an element does not exist in the set

elemUniqSetDirectly :: Unique -> UniqSet a -> Bool Source #

Check whether an element exists in the set based on the Unique contained in that element

Misc

subsetUniqSet Source #

Arguments

:: UniqSet a

Set A

-> UniqSet a

Set B

-> Bool 

Check whether a A is a subset of B

disjointUniqSet :: UniqSet a -> UniqSet a -> Bool Source #

Check whether A and B are disjoint

differenceUniqSet :: UniqSet a -> UniqSet a -> UniqSet a Source #

Take the difference of two sets

Conversions

Lists

mkUniqSet :: Uniquable a => [a] -> UniqSet a Source #

Create a set out of a list of elements that contain a Unique

eltsUniqSet :: UniqSet a -> [a] Source #

Get the elements of the set as a list