Copyright | (C) 2012-2016 University of Twente |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Smart constructor and destructor functions for CoreHW
Synopsis
- mkVec :: DataCon -> DataCon -> Type -> Integer -> [Term] -> Term
- appendToVec :: DataCon -> Type -> Term -> Integer -> [Term] -> Term
- extractElems :: Supply -> InScopeSet -> DataCon -> Type -> Char -> Integer -> Term -> (Supply, [(Term, [LetBinding])])
- extractTElems :: Supply -> InScopeSet -> DataCon -> DataCon -> Type -> Char -> Integer -> Term -> (Supply, ([Term], [LetBinding]))
- mkRTree :: DataCon -> DataCon -> Type -> Integer -> [Term] -> Term
- isSignalType :: TyConMap -> Type -> Bool
- isEnable :: TyConMap -> Type -> Bool
- isClockOrReset :: TyConMap -> Type -> Bool
- tyNatSize :: TyConMap -> Type -> Except String Integer
- mkUniqSystemTyVar :: (Supply, InScopeSet) -> (OccName, Kind) -> ((Supply, InScopeSet), TyVar)
- mkUniqSystemId :: (Supply, InScopeSet) -> (OccName, Type) -> ((Supply, InScopeSet), Id)
- mkUniqInternalId :: (Supply, InScopeSet) -> (OccName, Type) -> ((Supply, InScopeSet), Id)
- dataConInstArgTysE :: HasCallStack => InScopeSet -> TyConMap -> DataCon -> [Type] -> Maybe [Type]
- dataConInstArgTys :: DataCon -> [Type] -> Maybe [Type]
- primCo :: Type -> Term
- undefinedTm :: Type -> Term
- substArgTys :: DataCon -> [Type] -> [Type]
- tyLitShow :: TyConMap -> Type -> Except String String
- data Projections where
- Projections :: (forall m. MonadUnique m => InScopeSet -> Term -> m [Term]) -> Projections
- shouldSplit :: TyConMap -> Type -> Maybe ([Term] -> Term, Projections, [Type])
- shouldSplit0 :: TyConMap -> TypeView -> Maybe ([Term] -> Term, Projections, [Type])
- splitShouldSplit :: TyConMap -> [Type] -> [Type]
- stripIP :: Type -> Type
- inverseTopSortLetBindings :: HasCallStack => Term -> Term
- sccLetBindings :: HasCallStack => [LetBinding] -> [SCC LetBinding]
- mkSelectorCase :: HasCallStack => MonadUnique m => String -> InScopeSet -> TyConMap -> Term -> Int -> Int -> m Term
- mkWildValBinder :: MonadUnique m => InScopeSet -> Type -> m Id
- mkInternalVar :: MonadUnique m => InScopeSet -> OccName -> KindOrType -> m Id
Documentation
:: DataCon | The Nil constructor |
-> DataCon | The Cons (:>) constructor |
-> Type | Element type |
-> Integer | Length of the vector |
-> [Term] | Elements to put in the vector |
-> Term |
Create a vector of supplied elements
:: DataCon | The Cons (:>) constructor |
-> Type | Element type |
-> Term | The vector to append the elements to |
-> Integer | Length of the vector |
-> [Term] | Elements to append |
-> Term |
Append elements to the supplied vector
:: Supply | Unique supply |
-> InScopeSet | (Superset of) in scope variables |
-> DataCon | The Cons (:>) constructor |
-> Type | The element type |
-> Char | Char to append to the bound variable names |
-> Integer | Length of the vector |
-> Term | The vector |
-> (Supply, [(Term, [LetBinding])]) |
Create let-bindings with case-statements that select elements out of a vector. Returns both the variables to which element-selections are bound and the let-bindings
:: Supply | Unique supply |
-> InScopeSet | (Superset of) in scope variables |
-> DataCon | The |
-> DataCon | The |
-> Type | The element type |
-> Char | Char to append to the bound variable names |
-> Integer | Depth of the tree |
-> Term | The tree |
-> (Supply, ([Term], [LetBinding])) |
Create let-bindings with case-statements that select elements out of a tree. Returns both the variables to which element-selections are bound and the let-bindings
:: DataCon | The LR constructor |
-> DataCon | The BR constructor |
-> Type | Element type |
-> Integer | Depth of the tree |
-> [Term] | Elements to put in the tree |
-> Term |
Create a vector of supplied elements
isSignalType :: TyConMap -> Type -> Bool Source #
Determine whether a type is isomorphic to Clash.Signal.Internal.Signal
It is i.e.:
- Signal clk a
- (Signal clk a, Signal clk b)
- Vec n (Signal clk a)
- data Wrap = W (Signal clk' Int)
- etc.
This also includes BiSignals, i.e.:
- BiSignalIn High System Int
- etc.
isEnable :: TyConMap -> Type -> Bool Source #
Determines whether given type is an (alias of en) Enable line.
isClockOrReset :: TyConMap -> Type -> Bool Source #
Determines whether given type is an (alias of en) Clock or Reset line
mkUniqSystemTyVar :: (Supply, InScopeSet) -> (OccName, Kind) -> ((Supply, InScopeSet), TyVar) Source #
mkUniqSystemId :: (Supply, InScopeSet) -> (OccName, Type) -> ((Supply, InScopeSet), Id) Source #
mkUniqInternalId :: (Supply, InScopeSet) -> (OccName, Type) -> ((Supply, InScopeSet), Id) Source #
dataConInstArgTysE :: HasCallStack => InScopeSet -> TyConMap -> DataCon -> [Type] -> Maybe [Type] Source #
Same as dataConInstArgTys
, but it tries to compute existentials too,
hence the extra argument TyConMap
. WARNING: It will return the types
of non-existentials only
dataConInstArgTys :: DataCon -> [Type] -> Maybe [Type] Source #
Given a DataCon and a list of types, the type variables of the DataCon type are substituted for the list of types. The argument types are returned.
The list of types should be equal to the number of type variables, otherwise
Nothing
is returned.
undefinedTm :: Type -> Term Source #
Make an undefined term
tyLitShow :: TyConMap -> Type -> Except String String Source #
Try to reduce an arbitrary type to a literal type (Symbol or Nat), and subsequently extract its String representation
data Projections where Source #
Helper existential for shouldSplit
, contains a function that:
- given a term of a type that should be split,
- creates projections of that term for all the constructor arguments
Projections :: (forall m. MonadUnique m => InScopeSet -> Term -> m [Term]) -> Projections |
:: TyConMap | |
-> Type | Type to examine |
-> Maybe ([Term] -> Term, Projections, [Type]) | If we want to split values of the given type then we have Just:
Note that we only split one level at a time (although we check all the way down), e.g. given (Int, (Clock, Bool)) we return: Just ( (,) @Int @(Clock, Bool) , \s -> [case s of (a,b) -> a, case s of (a,b) -> b] , [Int, (Clock, Bool)]) An outer loop is required to subsequently split the (Clock, Bool) tuple. |
Determine whether we should split away types from a product type, i.e. clocks should always be separate arguments, and not part of a product.
shouldSplit0 :: TyConMap -> TypeView -> Maybe ([Term] -> Term, Projections, [Type]) Source #
Worker of shouldSplit
, works on TypeView
instead of Type
splitShouldSplit :: TyConMap -> [Type] -> [Type] Source #
Potentially split apart a list of function argument types. e.g. given:
[Int,(Clock,(Reset,Bool)),Char]
we return
[Int,Clock,Reset,Bool,Char]
But we would leave
[Int, (Bool,Int), Char]
unchanged.
inverseTopSortLetBindings :: HasCallStack => Term -> Term Source #
Do an inverse topological sorting of the let-bindings in a let-expression
sccLetBindings :: HasCallStack => [LetBinding] -> [SCC LetBinding] Source #
Group let-bindings into cyclic groups and acyclic individual bindings
:: HasCallStack | |
=> MonadUnique m | |
=> String | Name of the caller of this function |
-> InScopeSet | |
-> TyConMap | TyCon cache |
-> Term | Subject of the case-composition |
-> Int | n'th DataCon |
-> Int | n'th field |
-> m Term |
Make a case-decomposition that extracts a field out of a (Sum-of-)Product type
mkWildValBinder :: MonadUnique m => InScopeSet -> Type -> m Id Source #
Make a binder that should not be referenced
:: MonadUnique m | |
=> InScopeSet | |
-> OccName | Name of the identifier |
-> KindOrType | |
-> m Id |
Make a new, unique, identifier