DA.Either Samples
- carleslabonOP 2
Hello, good evening! I would like to ask on how we could implement DA.Either functions, since I’m having a hard time finding some sample codes.
Thanks!
- Gary_Verhaegen 5
Hi @carleslabon,
Implementing them yourself based on pattern matching may be a good learning experience. For an example syntax, if you wanted to convert an Either to a list, with an empty list for a
Rightand a single-element list for aLeft, you would write:keepLeft: Either a b -> [a] keepLeft e = case e of Right _ -> [] Left a -> [a]If you’re not after the exercise but just want to see how we did it, you can simply look at the source code for the DA.Either module.
- carleslabon 2