Skip to content

Instantly share code, notes, and snippets.

@Lysxia
Created August 1, 2019 12:23
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 Lysxia/3ec3f0f4f29fec7a000d811ec7c1e599 to your computer and use it in GitHub Desktop.
Save Lysxia/3ec3f0f4f29fec7a000d811ec7c1e599 to your computer and use it in GitHub Desktop.
{-# LANGUAGE RankNTypes, DerivingStrategies, GeneralizedNewtypeDeriving #-}
-- Defaults to newtype
newtype T_Def = T_Def Bool
deriving (Eq, Ord, Bounded)
-- Stock
newtype T_S = T_S Bool
deriving stock (Eq, Ord, Bounded)
-- Newtype
newtype T_NT = T_NT Bool
deriving newtype (Eq, Ord, Bounded)
-- Defaults to newtype (unless DeriveFunctor or DeriveFoldable are on)
newtype F_NT a = F_NT (Either Int a)
deriving (Functor, Foldable)
-- Defaults to newtype, fails
-- newtype F_NT_BAD a = F_NT_BAD (forall r. Either r a)
-- deriving (Functor, Foldable)
main = return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment