[Haskell-cafe] ANN: data-fix-cse -- Common subexpression elimination for EDSLs

Conal Elliott conal at conal.net
Sat Feb 23 02:12:42 CET 2013


On Tue, Feb 19, 2013 at 9:28 PM, Anton Kholomiov
<anton.kholomiov at gmail.com>wrote:

>
> Do you think the approach can be extended for non-regular (nested)
>> algebraic types (where the recursive data type is sometimes at a different
>> type instance)? For instance, it's very handy to use GADTs to capture
>> embedded language types in host language (Haskell) types, which leads to
>> non-regularity.
>>
>>
> I'm not sure I understand the case you are talking about. Can you write a
> simple example
> of the types like this?
>

Here's an example of a type-embedded DSEL, represented as a GADT:

> data E :: * -> * where
>   Lit :: Show a => a -> E a
>   Op  :: Op a -> E a
>   App :: E (a -> b) -> E a -> E b
>   ...
>
> data Op :: * -> * where
>   Add :: Num a => E (a -> a -> a)
>   Mul :: Num a => E (a -> a -> a)
>   Neg :: Num a => E (a -> a)
>   ...

-- Conal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130222/9ae5f093/attachment.htm>


More information about the Haskell-Cafe mailing list