Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Functor instance (Hilco Wijbenga) ---------------------------------------------------------------------- Message: 1 Date: Sun, 4 Mar 2018 11:41:38 -0800 From: Hilco Wijbenga <hilco.wijbe...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Functor instance Message-ID: <cae1poi37d0ag1kct7g0_h3pzprvw9ydfzvht51ryagbj0h-...@mail.gmail.com> Content-Type: text/plain; charset="UTF-8" On Sat, Mar 3, 2018 at 11:34 PM, Sumit Raja <sumitr...@gmail.com> wrote: >> I'm trying to implement my own Result type (and yes, I'm aware you can >> abuse Either for this :-) ) but doing something as (seemingly?) simple >> as implementing a Functor instance was surprisingly difficult. >> > Without knowing your final use case are Bifunctors what you are after > (https://hackage.haskell.org/package/base-4.10.1.0/docs/Data-Bifunctor.html)? > I used them when I wanted to fmap Left to convert errors to other > errors. No, they provide too much power. [I don't want to do anything more than die on the first error although I may add support for multiple errors later.] And I want to do this myself! No doubt, once I'm (far) more familiar with Haskell I'll be able to use things like Either and BiFunctor but right now they are just a step too far. I get lost in a forest of "weird" operators. :-) The purpose really is to work on something I fully understand (a Result type) and then see what I need to do in Haskell to support that. I just felt that the logical/intuitive type (at least to me) is "Result success failure" (it's the success value I really care about, after all) but that does not work with Functor (or Applicative, or Monad), AFAICT. So the order ("failure" first) seems to be forced on me. So be it. P.S. The second line in the Data.Bifunctor documentation made me chuckle: "Intuitively it is a bifunctor where both the first and second arguments are covariant.". Intuitive? Really? :-) ;-) ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 117, Issue 4 *****************************************