How to collapse Either in PureScript?

I have a type object Either String (Either String Int). I would like to collapse it to an object of type Either String Int.

Is there a provided function for this in PureScript?

+4
source share
1 answer

This is the same as Haskell:

import Prelude
import Data.Either

let a = Left "a" :: Either String (Either String Int)
let b = Right (Left "b") :: Either String (Either String Int)
let c = Right (Right 123) :: Either String (Either String Int)

join a -- Left "a"
join b -- Left "b"
join c -- Right 123
+4
source

Source: https://habr.com/ru/post/1664790/


All Articles