You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add derive via Generic example, and point to latest docs (documentationjs#331)
* Add derive via Generic example, and point to latest docs
I often visit this page looking for a `genericShow` example.
It was also frustrating to click on the `Data.Generic.Rep` and be taken to an older package version that's missing lots of nice documentation. So ensuring links now go to the latest version. (related to purescript/pursuit#414)
* Clarify `derive` and more details on `Generic`
Note that `derive instance` is not the only mechanism for allowing you to avoid writing out boilerplate type class instance code. Many type classes not listed here can be derived through other means, such as via a Generic instance. For example, here's how to create a `Show` instance for `Person` via `genericShow`:
157
+
158
+
```purescript
159
+
import Data.Generic.Rep (class Generic)
160
+
import Data.Generic.Rep.Show (genericShow)
161
+
162
+
derive instance genericPerson :: Generic Person _
163
+
164
+
instance showPerson :: Show Person where
165
+
show = genericShow
166
+
```
167
+
168
+
More information on Generic deriving is available [in the generics-rep library documentation](https://pursuit.purescript.org/packages/purescript-generics-rep).
0 commit comments