我有Either String (Either String Int)
类型的对象。我想将它折叠为Either String Int
类型的对象。
PureScript中是否提供了此功能?
答案 0 :(得分:4)
与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