Skip to content

Instantly share code, notes, and snippets.

@hadronized
Created May 19, 2018 23:36
Show Gist options
  • Save hadronized/1165b7e252c4e4f89a143df92c7d8d56 to your computer and use it in GitHub Desktop.
Save hadronized/1165b7e252c4e4f89a143df92c7d8d56 to your computer and use it in GitHub Desktop.
{-# 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)
@hadronized
Copy link
Author

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