[Haskell-beginners] understanding function signature alignement

simkestuff at gmail.com simkestuff at gmail.com
Fri Aug 10 12:25:56 UTC 2018


Yes, thinking it the terms that something which is absolutely free to be
whatever, can be restricted and reduced into something else while other way
around is not possible is usefull;
thanks

On Fri, Aug 10, 2018 at 12:06 PM Theodore Lief Gannon <tanuki at gmail.com>
wrote:

> You're right that the return type is more restricted than the argument,
> but it's in an *absolute* sense, not a relative one. It's not possible to
> relax `m d` to make it the same type as `c`, but it IS possible to
> constrain `c` to be the same as `m d`! And that's how `id` works here: the
> input in this case is known to be the same type as the output. You need
> something wrapped in a monad, and you already have that, so you just use it
> as-is.
>
> On Thu, Aug 9, 2018, 7:22 AM simkestuff at gmail.com <simkestuff at gmail.com>
> wrote:
>
>> Thanks, it is still a bit fuzzy to me ...
>>
>>
>> I understand what you did  but what confuses me is that when i look at
>> function with signature like
>>
>> f :: Monad m => c -> m d
>>
>> I always think that return type is somehow restricted in comparison to
>> input because it demands that output type is wraped inside something (monad
>> in this case).
>>
>> For such signature to fit id signature (a -> a) ,  c type shoud be also
>> wraped inside monad but it is not case here...
>>
>> Anyhow, I still have to figure it out
>>
>> thanks
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180810/f5ed4f6c/attachment.html>


More information about the Beginners mailing list