Is there a standard name or implementation of the “purely applicative Either”?

后端 未结 1 1079
萌比男神i
萌比男神i 2021-02-09 05:53

I frequently find use for what I call the \"purely applicative Either\", i.e. Either with the Applicative instance available so long as we

1条回答
  •  长发绾君心
    2021-02-09 06:12

    This looks pretty similar to the AccValidation type in the validation package: http://hackage.haskell.org/package/validation-0.3.1/docs/Data-Validation.html

    Edit:

    In particular the following instance declaration:

    instance Semigroup err => Apply (AccValidation err) where
      AccFailure e1 <.> AccFailure e2 =
        AccFailure (e1 <> e2)
      AccFailure e1 <.> AccSuccess _  =
        AccFailure e1
      AccSuccess _  <.> AccFailure e2 =
        AccFailure e2
      AccSuccess f  <.> AccSuccess a  =
        AccSuccess (f a)
    

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