Created
March 30, 2018 21:45
-
-
Save sjoerdvisscher/98909968cefc17d2bd58026bfbb38552 to your computer and use it in GitHub Desktop.
http://reasonablypolymorphic.com/blog/higher-kinded-data with one-liner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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