module Data.Invertible.Either
( switch
, isLeft
, isRight
, lft
, rgt
) where
import Prelude
import Data.Invertible.Bijection
import Data.Invertible.TH
switch :: Either a b <-> Either b a
switch =
[biCase|
Left a <-> Right a
Right a <-> Left a
|]
isLeft :: Either () () <-> Bool
isLeft =
[biCase|
Left () <-> True
Right () <-> False
|]
isRight :: Either () () <-> Bool
isRight =
[biCase|
Right () <-> True
Left () <-> False
|]
lft :: Either a () <-> Maybe a
lft =
[biCase|
Left a <-> Just a
Right () <-> Nothing
|]
rgt :: Either () a <-> Maybe a
rgt =
[biCase|
Left () <-> Nothing
Right a <-> Just a
|]