Export Stock, Stock1 modifiers with virtual stock instances
I propose two newtypes in base to replace and generalize the stock
deriving strategy
type Stock :: Type -> Type
newtype Stock a = Stock a
type Stock1 :: (k -> Type) -> (k -> Type)
newtype Stock1 f a = Stock1 (f a)
with magical compiler instances every time deriving stock Cls
works then the instance for Cls (Stock a)
or Cls (Stock1 f)
should be generated, depending on the kind of Cls
's argument. The purpose is to simplify deriving (Haskell Proposal: Simplify Deriving) and to make stock deriving first-class. I think we can soon derive Traversable
:) so I will include it
type Medal :: Type
data Medal = Gold | Silver | Bronze
deriving (Eq, Ord)
via Stock Medal
type List :: Type
data List a = Nil | Cons a (List a)
deriving (Functor, Foldable, Traversable)
via Stock1 List
Them being "first-class" means they are now types like any other modifier and can be combined into more complicated behaviours, Down
reverses the stock instance and Reverse
reverses the order of processing to be right-to-left.
type Medal :: Type
data Medal = Bronze | Silver | Gold
deriving (Eq, Ord)
via Down (Stock Medal)
type Snoc :: Type
data Snoc a = Nil | Snoc (Snoc a) a
deriving (Functor, Foldable, Traversable)
via Reverse (Stock1 Snoc)
Edited by Icelandjack