[Haskell-cafe] Is it possible to represent such polymorphism?

Alberto G. Corona agocorona at gmail.com
Wed Oct 5 13:45:56 CEST 2011


If a newbie considers this as something natural, this is another reason for
syntactic sugaring of HList:

http://www.haskell.org/pipermail/haskell-cafe/2011-April/090986.html

2011/10/2 Du Xi <sdiyazg at sjtu.edu.cn>

> --I tried to write such polymorphic function:
>
> expand (x,y,z) = (x,y,z)
> expand (x,y) = (x,y,1)
>
> --And it didn't compile. Then I added a type signature:
>
> expand::a->b
> expand (x,y,z) = (x,y,z)
> expand (x,y) = (x,y,1)
>
> --It still didn't compile. I think the reason is that the following is
> disallowed:
>
> f::a->b
> f x = x
>
> --Is it possible to get around this and write the "expand" function? Of
> course, x and y may be of different types
>
>
>
> ______________________________**_________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/**mailman/listinfo/haskell-cafe<http://www.haskell.org/mailman/listinfo/haskell-cafe>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111005/e864ec35/attachment.htm>


More information about the Haskell-Cafe mailing list