Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

Interpreter to duplicate the representation of an expression in order to evaluate it with different interpreters.

NOTE: this is a more verbose, less clear,
and maybe less efficient alternative
to maintaining the universal polymorphism of `repr`

either using `NoMonomorphismRestriction`

when writing an EDSL,
or with a `forall repr.`

within a data type
when writing a DSL; as is done when parsing `Term`

in this library;
it is thus mainly here for the sake of curiosity.

## Synopsis

- data Dup repr1 repr2 a = Dup {}
- dup0 :: (cl x, cl y) => (forall repr. cl repr => repr a) -> Dup x y a
- dup1 :: (cl x, cl y) => (forall repr. cl repr => repr a -> repr b) -> Dup x y a -> Dup x y b
- dup2 :: (cl x, cl y) => (forall repr. cl repr => repr a -> repr b -> repr c) -> Dup x y a -> Dup x y b -> Dup x y c
- dup3 :: (cl x, cl y) => (forall repr. cl repr => repr a -> repr b -> repr c -> repr d) -> Dup x y a -> Dup x y b -> Dup x y c -> Dup x y d
- dupList :: [Dup x y a] -> ([x a], [y a])

# Type

`Dup`

data Dup repr1 repr2 a infixl 2 Source #

Duplicate an implicitly generated representation.

Useful to combine two symantic interpreters into one.

## Instances

(Functor x, Functor y) => Functor (Dup x y) Source # | |

(Applicative x, Applicative y) => Applicative (Dup x y) Source # | |

(Alternative x, Alternative y) => Alternative (Dup x y) Source # | |

(Sym_Lambda r1, Sym_Lambda r2) => Sym_Lambda (Dup r1 r2) Source # | |

Defined in Language.Symantic.Compiling.Term apply :: Dup r1 r2 ((a -> b) -> a -> b) Source # app :: Dup r1 r2 (a -> b) -> Dup r1 r2 a -> Dup r1 r2 b Source # lam :: (Dup r1 r2 a -> Dup r1 r2 b) -> Dup r1 r2 (a -> b) Source # let_ :: Dup r1 r2 var -> (Dup r1 r2 var -> Dup r1 r2 res) -> Dup r1 r2 res Source # lam1 :: (Dup r1 r2 a -> Dup r1 r2 b) -> Dup r1 r2 (a -> b) Source # qual :: proxy q -> Dup r1 r2 t -> Dup r1 r2 (q #> t) Source # |

# Helpers

dup0 :: (cl x, cl y) => (forall repr. cl repr => repr a) -> Dup x y a Source #

To be used with the `TypeApplications`

language extension:
```
dup0 @Sym_Foo foo
```

dup1 :: (cl x, cl y) => (forall repr. cl repr => repr a -> repr b) -> Dup x y a -> Dup x y b Source #

dup2 :: (cl x, cl y) => (forall repr. cl repr => repr a -> repr b -> repr c) -> Dup x y a -> Dup x y b -> Dup x y c Source #