synthesizer-llvm-0.9: Efficient signal processing using runtime compilation

Safe HaskellNone

Synthesizer.LLVM.Parameter

Synopsis

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

arr is useful for lifting parameter selectors to our parameter type without relying on the constructor.

Category T

. can be used for fetching a parameter from a super-parameter.

Monad (T p) 
Functor (T p)

Useful for splitting T p (a,b) into T p a and T p b using fmap fst and fmap snd.

Applicative (T p)

Useful for combining T p a and T p b to T p (a,b) using liftA2 (,). However, we do not recommend to do so because the result parameter can only be constant if both operands are constant.

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) 

get :: T p a -> p -> a

($#) :: (T p a -> b) -> a -> b

class Tuple tuple where

Associated Types

type Composed tuple :: *

type Source tuple :: *

Methods

decompose :: T (Source tuple) (Composed tuple) -> tuple

Instances

(Tuple a, Tuple b, ~ * (Source a) (Source b)) => Tuple (a, b) 
Tuple (T p a) 
(Tuple a, Tuple b, Tuple c, ~ * (Source a) (Source b), ~ * (Source b) (Source c)) => Tuple (a, b, c) 

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 Int. The problem is that the type checker cannot infer that an element is a 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