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
- shouldSplit :: TyConMap -> Type -> Maybe (Term, [Type])
- shouldSplit0 :: TyConMap -> TypeView -> Maybe (Term, [Type])
- splitShouldSplit :: TyConMap -> [Type] -> [Type]
- stripIP :: Type -> Type
- inverseTopSortLetBindings :: HasCallStack => Term -> Term

# 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

:: TyConMap | |

-> Type | Type to examine |

-> Maybe (Term, [Type]) | If we want to split values of the given type then we have - The (type-applied) data-constructor which, when applied to values of the types in 2., creates a value of the examined type
- The arguments types of the product we are trying to split.
Note that we only split one level at a time (although we check all the way
down), e.g. given Just ((,) @Int @(Clock, Bool), [Int, (Clock, Bool)]) An outer loop is required to subsequently split the |

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, [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