... | ... | @@ -467,10 +467,10 @@ fmap f (Bar a)=(\b ->Bar b)(fmap f a) |
|
|
There are more classes in `base` that we could derive!
|
|
|
|
|
|
|
|
|
In particular, the `Bifunctor` class (born from the [ bifunctors](http://hackage.haskell.org/package/bifunctors) library) [ was added](https://ghc.haskell.org/trac/ghc/ticket/9682) to `base` in GHC 7.10, and [ there are plans](https://ghc.haskell.org/trac/ghc/ticket/10448) to add `Bifoldable` and `Bitraversable` to `base` in the future. All three classes could be derived in much the same way as their cousins `Functor`, `Foldable`, and `Traversable`. The existing algorithms would simply need to be adapted to accommodate two type parameters instead of one. The [ Data.Bifunctor.TH](https://github.com/ekmett/bifunctors/blob/c2e7717e1913dc53ad934b3d0ddd74d077b965c3/src/Data/Bifunctor/TH.hs) module from the `bifunctors` library demonstrates an implementation of the following proposal using Template Haskell.
|
|
|
In particular, the `Bifunctor` class (born from the [ bifunctors](http://hackage.haskell.org/package/bifunctors) library) [ was added](https://ghc.haskell.org/trac/ghc/ticket/9682) to `base` in GHC 7.10, and the `Bifoldable` and `Bitraversable` classes (also from `bifunctors`) [ were added](https://ghc.haskell.org/trac/ghc/ticket/10448) to `base` in GHC 8.2. All three classes could be derived in much the same way as their cousins `Functor`, `Foldable`, and `Traversable`. The existing algorithms would simply need to be adapted to accommodate two type parameters instead of one. The [ Data.Bifunctor.TH](http://hackage.haskell.org/package/bifunctors-5.3/docs/Data-Bifunctor-TH.html) module from the `bifunctors` library demonstrates an implementation of the following proposal using Template Haskell.
|
|
|
|
|
|
|
|
|
In GHC 8.0, higher-order versions of the `Eq`, `Ord`, `Read`, and `Show` typeclasses were added to `base` in the `Data.Functor.Classes` module (which originally lived in the `transformers` library). These classes are generalized to work over datatypes indexed by one type parameter (for `Eq1`, `Ord1`, `Read1`, and `Show1`) or by two type parameters (`Eq2`, `Ord2`, `Read2`, and `Show2`). Haskell programmers have been able to derive `Eq`, `Ord`, `Read`, and `Show` for a long time, so it wouldn't be hard at all to envision a deriving mechanism for `Eq1`, `Eq2`, and friends which takes advantage of tricks that `DeriveFunctor` uses.
|
|
|
In GHC 8.0, higher-order versions of the `Eq`, `Ord`, `Read`, and `Show` typeclasses were added to `base` in the `Data.Functor.Classes` module (which originally lived in the `transformers` library). These classes are generalized to work over datatypes indexed by one type parameter (for `Eq1`, `Ord1`, `Read1`, and `Show1`) or by two type parameters (`Eq2`, `Ord2`, `Read2`, and `Show2`). Haskell programmers have been able to derive `Eq`, `Ord`, `Read`, and `Show` for a long time, so it wouldn't be hard at all to envision a deriving mechanism for `Eq1`, `Eq2`, and friends which takes advantage of tricks that `DeriveFunctor` uses. The [ deriving-compat](http://hackage.haskell.org/package/deriving-compat-0.3) library demonstrates proofs-of-concept for deriving [ Eq1/2](http://hackage.haskell.org/package/deriving-compat-0.3/docs/Data-Eq-Deriving.html), [ Ord1/2](http://hackage.haskell.org/package/deriving-compat-0.3/docs/Data-Ord-Deriving.html), [ Read1/2](http://hackage.haskell.org/package/deriving-compat-0.3/docs/Text-Read-Deriving.html), and [ Show1/2](http://hackage.haskell.org/package/deriving-compat-0.3/docs/Text-Show-Deriving.html) using Template Haskell.
|
|
|
|
|
|
### Classes
|
|
|
|
... | ... | |