Skip to content

Instantly share code, notes, and snippets.

@phaazon

phaazon/NT.hs

Created May 19, 2018
Embed
What would you like to do?
{-# LANGUAGE RankNTypes #-}
-- A natural transformation.
data NT f g = NT { nt :: forall a. f a -> g a }
-- Natural transformation from Maybe to [].
maybeListNT :: NT Maybe []
maybeListNT = NT (maybe [] pure)
@phaazon

This comment has been minimized.

Copy link
Owner Author

@phaazon phaazon commented May 19, 2018

You can test it with:

nt maybeListNT (Just "hey")

Which yields

["hey"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.