Skip to content

Instantly share code, notes, and snippets.

@clayrat
Created December 1, 2017 14:53
Show Gist options
  • Select an option

  • Save clayrat/acfb3a69fd533f5832aff9debea54af4 to your computer and use it in GitHub Desktop.

Select an option

Save clayrat/acfb3a69fd533f5832aff9debea54af4 to your computer and use it in GitHub Desktop.
decAnd : Dec a -> Dec b -> Dec (a,b)
decAnd (Yes a) (Yes b) = Yes (a, b)
decAnd _ (No nb) = No (nb . snd)
decAnd (No na) _ = No (na . fst)
decOr : Dec a -> Dec b -> Dec (Either a b)
decOr (Yes a) _ = Yes (Left a)
decOr _ (Yes b) = Yes (Right b)
decOr (No na) (No nb) = No (either na nb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment