[Haskell-beginners] understanding function signature alignement
Theodore Lief Gannon
tanuki at gmail.com
Fri Aug 10 10:05:44 UTC 2018
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180810/484a8744/attachment-0001.html>
More information about the Beginners
mailing list