Safe Haskell | None |
---|
Synthesizer.LLVM.Parameter
- data T p a
- get :: T p a -> p -> a
- ($#) :: (T p a -> b) -> a -> b
- class Tuple tuple where
- withTuple :: (Tuple tuple, ~ * (Source tuple) p, ~ * (Composed tuple) p) => (tuple -> f p) -> f p
- withTuple1 :: (Tuple tuple, ~ * (Source tuple) p, ~ * (Composed tuple) p) => (tuple -> f p a) -> f p a
- withTuple2 :: (Tuple tuple, ~ * (Source tuple) p, ~ * (Composed tuple) p) => (tuple -> f p a b) -> f p a b
Documentation
data T p a
This data type is for parameters of parameterized LLVM code.
It is better than using plain functions of type p -> a
since it allows for numeric instances
and we can make explicit,
whether a parameter is constant.
We recommend to use parameters for atomic types.
Although a parameter of type T p (a,b)
is possible,
it means that the whole parameter is variable
if only one of the pair elements is variable.
This way you may miss opportunities for constant folding.
Instances
Arrow T |
|
Category T |
|
Monad (T p) | |
Functor (T p) | Useful for splitting |
Applicative (T p) | Useful for combining |
Floating a => Floating (T p a) | |
Fractional a => Fractional (T p a) | |
Num a => Num (T p a) | |
Tuple (T p a) | |
C a => C (T p a) | |
C a => C (T p a) | |
C a => C (T p a) | |
C a => C (T p a) | |
C a => C (T p a) |
class Tuple tuple where
withTuple :: (Tuple tuple, ~ * (Source tuple) p, ~ * (Composed tuple) p) => (tuple -> f p) -> f p
Provide all elements of a nested tuple as separate parameters.
If you do not use one of the tuple elements,
you will get a type error like
Couldn't match type `Param.Composed t0' with
.
The problem is that the type checker cannot infer
that an element is a Int
Parameter.T
if it remains unused.
withTuple1 :: (Tuple tuple, ~ * (Source tuple) p, ~ * (Composed tuple) p) => (tuple -> f p a) -> f p a
withTuple2 :: (Tuple tuple, ~ * (Source tuple) p, ~ * (Composed tuple) p) => (tuple -> f p a b) -> f p a b