{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -Wno-name-shadowing #-}
{-# OPTIONS_GHC -fno-omit-interface-pragmas #-}
module PlutusTx.These(
These(..)
, these
, theseWithDefault
) where
data These a b = This a | That b | These a b
{-# INLINABLE theseWithDefault #-}
theseWithDefault :: a -> b -> (a -> b -> c) -> These a b -> c
theseWithDefault :: a -> b -> (a -> b -> c) -> These a b -> c
theseWithDefault a
a' b
b' a -> b -> c
f = \case
This a
a -> a -> b -> c
f a
a b
b'
That b
b -> a -> b -> c
f a
a' b
b
These a
a b
b -> a -> b -> c
f a
a b
b
{-# INLINABLE these #-}
these :: (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c
these :: (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c
these a -> c
f b -> c
g a -> b -> c
h = \case
This a
a -> a -> c
f a
a
That b
b -> b -> c
g b
b
These a
a b
b -> a -> b -> c
h a
a b
b