Re: data families syntax

2016-11-13 Thread Harendra Kumar
Answering my own question, which means I did not do enough research before
asking. I found two points that I missed earlier:

1) data families are open in contrast to value level functions i.e. you can
add more instances later on hence the family and instance keywords make
sense.

2) the syntax 'data family List :: * -> *' is actually already supported as
an alternative.

-harendra


On 13 November 2016 at 16:10, Harendra Kumar <harendra.ku...@gmail.com>
wrote:

> I am curious about why the data families syntax was chosen to be the way
> it is. For example a list can be defined as follows:
>
> data family List a
>
> data instance List Char = Empty | Cons Char (List Char)
>
> data instance List ()   = Count Int
>
>
> Instead why not define it as:
>
> data List :: * -> *
>
> data List Char = Empty | Cons Char (List Char)
>
> data List ()   = Count Int
>
>
> The latter form looks more intuitive and easy to remember to me since it
> is very similar to the way value level functions are defined (signature &
> pattern matching defs). Here we are just defining a type level function
> instead.
>
> -harendra
>
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


data families syntax

2016-11-13 Thread Harendra Kumar
I am curious about why the data families syntax was chosen to be the way it
is. For example a list can be defined as follows:

data family List a

data instance List Char = Empty | Cons Char (List Char)

data instance List ()   = Count Int


Instead why not define it as:

data List :: * -> *

data List Char = Empty | Cons Char (List Char)

data List ()   = Count Int


The latter form looks more intuitive and easy to remember to me since it is
very similar to the way value level functions are defined (signature &
pattern matching defs). Here we are just defining a type level function
instead.

-harendra
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs