Skip to content
CCPEDIAby Unity Nodes
App Development

DA.Either Samples

3 posts366 views9 likesLast activity Sep 2020

  1. 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!

  2. 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 Right and a single-element list for a Left, 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.

  3. carleslabon 2

    Hello @Gary_Verhaegen,

    I’ll try this one on my end.

    Thanks.