Skip to content

Instantly share code, notes, and snippets.

@sjoerdvisscher
Created March 30, 2018 21:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjoerdvisscher/98909968cefc17d2bd58026bfbb38552 to your computer and use it in GitHub Desktop.
Save sjoerdvisscher/98909968cefc17d2bd58026bfbb38552 to your computer and use it in GitHub Desktop.
{-# LANGUAGE FlexibleContexts, FlexibleInstances, TypeApplications, MultiParamTypeClasses, GADTs #-}
import Generics.OneLiner.Binary
import Data.Functor.Identity
class IsMaybe s s' where isMaybe :: s -> Maybe s'
instance (s ~ Maybe s') => IsMaybe s s' where isMaybe = id
validate
:: (ADT (f Maybe) (f Identity), Constraints (f Maybe) (f Identity) IsMaybe)
=> f Maybe
-> Maybe (f Identity)
validate = gtraverse @IsMaybe isMaybe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment