mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-16 06:45:44 +08:00
17 lines
528 B
Agda
17 lines
528 B
Agda
|
module FFI.Data.Either where
|
||
|
|
||
|
{-# FOREIGN GHC import qualified Data.Either #-}
|
||
|
|
||
|
data Either (A B : Set) : Set where
|
||
|
Left : A → Either A B
|
||
|
Right : B → Either A B
|
||
|
{-# COMPILE GHC Either = data Data.Either.Either (Data.Either.Left|Data.Either.Right) #-}
|
||
|
|
||
|
mapLeft : ∀ {A B C} → (A → B) → (Either A C) → (Either B C)
|
||
|
mapLeft f (Left x) = Left (f x)
|
||
|
mapLeft f (Right x) = Right x
|
||
|
|
||
|
mapRight : ∀ {A B C} → (B → C) → (Either A B) → (Either A C)
|
||
|
mapRight f (Left x) = Left x
|
||
|
mapRight f (Right x) = Right (f x)
|