How do I collapse an Either in PureScript?

489 views Asked by At

I have an object of type 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?

1

There are 1 answers

1
sdgfsdh On BEST ANSWER

It 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