... | ... | @@ -72,6 +72,8 @@ mappend=(<>) |
|
|
|
|
|
## Writing compatible code
|
|
|
|
|
|
### Recommended Variant
|
|
|
|
|
|
|
|
|
The code below is expected to be `-Wcompat -Wall` clean
|
|
|
(see also [ https://groups.google.com/forum/\#!msg/haskell-core-libraries/PyxpE2ebS9Q/Ni0ywo_GCgAJ](https://groups.google.com/forum/#!msg/haskell-core-libraries/PyxpE2ebS9Q/Ni0ywo_GCgAJ))
|
... | ... | @@ -94,6 +96,29 @@ if !impl(ghc >= 8.0) |
|
|
|
|
|
to provide a legacy `Semigroup` class.
|
|
|
|
|
|
### Alternative w/ conditionally defined `Semigroup` instance & -XCPP
|
|
|
|
|
|
|
|
|
This variant can be used if you require support for GHC \< 8.0 **and** you do **not** want to depend on the `semigroups` package.
|
|
|
|
|
|
```
|
|
|
#ifMIN_VERSION_base(4,9,0)-- Data.Semigroup was added in base-4.9importData.Semigroupas Sem
|
|
|
#endif
|
|
|
#if!(MIN_VERSION_base(4,8,0))-- starting with base-4.8, Monoid is rexported from PreludeimportData.Monoid#endif
|
|
|
|
|
|
appendFoo::Foo->Foo->FooappendFoo=…emptyFoo::FooemptyFoo=…#ifMIN_VERSION_base(4,9,0)instanceSem.SemigroupFoowhere(<>)= appendFoo
|
|
|
#endif
|
|
|
|
|
|
instanceMonoidFoowhere
|
|
|
mempty = emptyFoo
|
|
|
|
|
|
#ifMIN_VERSION_base(4,11,0)-- starting with base-4.11, mappend definitions are redundant;-- at some point `mappend` will be removed from `Monoid`#elif MIN_VERSION_base(4,9,0)
|
|
|
mappend =(Sem.<>)#else// base <4.9-- prior to GHC 8.0 / base-4.9 where no `Semigroup` class existed
|
|
|
mappend = appendFoo
|
|
|
# endif
|
|
|
|
|
|
```
|
|
|
|
|
|
---
|
|
|
|
|
|
TODO …integrate migration roadmap outlined in [ http://permalink.gmane.org/gmane.comp.lang.haskell.libraries/24526](http://permalink.gmane.org/gmane.comp.lang.haskell.libraries/24526) |
|
|
\ No newline at end of file |