Skip to content

Instantly share code, notes, and snippets.

@Akii
Created November 12, 2018 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akii/cb2c97c1af9be95f4c76b9b6aa0d024d to your computer and use it in GitHub Desktop.
Save Akii/cb2c97c1af9be95f4c76b9b6aa0d024d to your computer and use it in GitHub Desktop.
newtype NT = NT String
foo :: Maybe NT
foo = Just (NT "test")
bar :: Maybe NT -> Maybe String
bar = undefined -- ??? how to do this?
-- this would work but it verbose for multiple data constructors
bar (Just $ NT s) = Just s
bar Nothing = Nothing
unNT :: NT -> String
unNT (NT string) = string
bar = fmap unNT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment