{-# OPTIONS_GHC -fno-omit-interface-pragmas #-}
module PlutusTx.Either (Either(..), isLeft, isRight, either) where

{-
We export off-chain Haskell's Either type as on-chain Plutus's Either type since they are the same.
-}

import PlutusTx.Bool (Bool (..))
import Prelude (Either (..))


{- HLINT ignore -}

{-# INLINABLE isLeft #-}
-- | Return `True` if the given value is a `Left`-value, `False` otherwise.
isLeft :: Either a b -> Bool
isLeft :: forall a b. Either a b -> Bool
isLeft (Left a
_)  = Bool
True
isLeft (Right b
_) = Bool
False

{-# INLINABLE isRight #-}
-- | Return `True` if the given value is a `Right`-value, `False` otherwise.
isRight :: Either a b -> Bool
isRight :: forall a b. Either a b -> Bool
isRight (Left a
_)  = Bool
False
isRight (Right b
_) = Bool
True

{-# INLINABLE either #-}
-- | Plutus Tx version of 'Prelude.either'
either :: (a -> c) -> (b -> c) -> Either a b -> c
either :: forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either a -> c
f b -> c
_ (Left a
x)  = a -> c
f a
x
either a -> c
_ b -> c
g (Right b
y) = b -> c
g b
y