Mapping over Either's Left

前端 未结 4 1678
慢半拍i
慢半拍i 2021-02-02 11:48

Somewhere in my app I receive an Either ParserError MyParseResult from Parsec. Downstream this result gets some other parsing done over using other libs. During tha

4条回答
  •  伪装坚强ぢ
    2021-02-02 12:14

    Another option is to use Bifunctor instance of Either. Then you have

    first :: (a -> b) -> Either a c -> Either b c
    

    (Also Bifunctor can be used to traverse over the first part of (a,b).)

提交回复
热议问题