Question on nested fmaps.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question on nested fmaps.

David Banas-2
Is this true, in general?:

fmap h (fmap g f) == fmap (h . g) f

Is there a simple proof?

Thanks,
-db


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Question on nested fmaps.

Adam Bergmark-2
This is one of the functor laws, the other one being `fmap id = id'. If it doesn't hold your type *should* not have a Functor instance, but the compiler doesn't verify this for you.

HTH,
Adam

On Thu, Dec 31, 2015 at 2:15 AM, David Banas <[hidden email]> wrote:
Is this true, in general?:

fmap h (fmap g f) == fmap (h . g) f

Is there a simple proof?

Thanks,
-db


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Question on nested fmaps.

Roman Cheplyaka-2
This law implies from fmap id = id, see
https://www.fpcomplete.com/user/edwardk/snippets/fmap

On 12/31/2015 03:27 AM, Adam Bergmark wrote:

> This is one of the functor laws, the other one being `fmap id = id'. If
> it doesn't hold your type *should* not have a Functor instance, but the
> compiler doesn't verify this for you.
>
> HTH,
> Adam
>
> On Thu, Dec 31, 2015 at 2:15 AM, David Banas <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Is this true, in general?:
>
>         fmap h (fmap g f) == fmap (h . g) f
>
>
>     Is there a simple proof?
>
>     Thanks,
>     -db
>
>
>     _______________________________________________
>     Haskell-Cafe mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

signature.asc (836 bytes) Download Attachment