Is there no standard (Either a) monad instance?

前端 未结 4 1868
一整个雨季
一整个雨季 2021-01-01 18:14

I was under the impression that there was an instance for Either a somewhere, but I can\'t seem to find it. I have tried importing Control.Monad, Control.Monad.Instances and

相关标签:
4条回答
  • 2021-01-01 18:26

    As of base 4.6, the instance is in Data.Either itself.

    0 讨论(0)
  • 2021-01-01 18:32

    This instance has been added in base 4.3.x.x, which comes with ghc 7. Meanwhile, you can use the Either instance directly, or, if you are using Either to represent something that may fail you should use ErrorT monad transformer.

    0 讨论(0)
  • 2021-01-01 18:43

    There is not an instance for Either a, but there is for Either String in Control.Monad.Error. (Actually, it's for Error e => Either e, IIRC).

    0 讨论(0)
  • 2021-01-01 18:49

    I believe there's something in Control.Monad.Error - don't have anything to check, though.

    0 讨论(0)
提交回复
热议问题