[Haskell-cafe] Intanciate data type

Gautier DI FOLCO gautier.difolco at gmail.com
Mon Jul 4 21:31:08 UTC 2016


Hello,

I would say that type families should do the joke:

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
type family Prod a where
  Prod String    = Int
  Prod (Maybe a) = a

data Foo e a
where

   Foo :: e -> Foo (Prod e) a

Regards.

2016-07-04 22:43 GMT+02:00 Corentin Dupont <corentin.dupont at gmail.com>:

> Hi all,
> I have a data type looking like this:
>
> data Foo e a
> where
>
>    Foo :: e →  Foo e a
>
> I would like to instantiate it to make it equivalent to:
>
> data Bar a
> where
>
>    A :: String    →  Bar Int
>    B :: Maybe a     →  Bar a
>
> How can I do that? With a functional dependency?
> I probably need to change the definition of Foo.
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160704/b3bf3d19/attachment.html>


More information about the Haskell-Cafe mailing list