1 {-# LANGUAGE ConstraintKinds #-}
2 -- | Interpreter to duplicate the representation of an expression
3 -- in order to evaluate it with different interpreters.
5 -- NOTE: this is a more verbose, less clear,
6 -- and maybe less efficient alternative
7 -- to maintaining the universal polymorphism of @repr@ at parsing time
8 -- as done with 'Forall_Repr_with_Context';
9 -- it is mainly here for the sake of curiosity.
10 module Language.Symantic.Interpreting.Dup where
14 -- | Interpreter's data.
15 data DupI repr1 repr2 a
24 -> (forall repr. cl repr => repr a)
26 dupI0 _cl f = f `DupI` f
31 -> (forall repr. cl repr => repr a -> repr b)
34 dupI1 _cl f (a1 `DupI` a2) =
40 -> (forall repr. cl repr => repr a -> repr b -> repr c)
44 dupI2 _cl f (a1 `DupI` a2) (b1 `DupI` b2) =
45 f a1 b1 `DupI` f a2 b2
50 -> (forall repr. cl repr => repr a -> repr b -> repr c -> repr d)
55 dupI3 _cl f (a1 `DupI` a2) (b1 `DupI` b2) (c1 `DupI` c2) =
56 f a1 b1 c1 `DupI` f a2 b2 c2