1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 23:11:50 +03:00

Define these for case analysis over These.

This commit is contained in:
Rob Rix 2016-03-10 13:14:29 -05:00
parent 912823b2cd
commit d792ddcd57

View File

@ -5,6 +5,12 @@ import Data.Bifunctor
data These a b = This a | That b | These a b
deriving (Eq, Show)
-- | Eliminate These by case analysis.
these :: (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c
these f _ _ (This this) = f this
these _ f _ (That that) = f that
these _ _ f (These this that) = f this that
-- Instances