Skip to content

docs(generic): update genericShow module reference #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2021

Conversation

sevillaarvin
Copy link
Contributor

@sevillaarvin sevillaarvin commented Apr 19, 2021

I tried executing the code found in the Generic section but kept getting an error:

Data.Generic.Rep.Show
#+begin_src purescript
import Data.Generic.Rep (class Generic)
-- import Data.Show.Generic (genericShow)
import Data.Generic.Rep.Show (genericShow)
import Effect.Console (logShow)

newtype Score = Score Int

:paste

-- generic deriving prints wrapper with show
derive instance genericScore :: Generic Score _
instance showScore :: Show Score where
  show = genericShow

main = logShow (Score 5)
-- Prints:
-- (Score 5)
#+end_src

#+RESULTS:
#+begin_example
PSCi, version 0.14.0
Type :? for help

import Prelude

> > > Error found:
in module �[33m$PSCI�[0m
at <internal>:0:0 - 0:0 (line 0, column 0 - line 0, column 0)

  Unknown module �[33mData.Generic.Rep.Show�[0m


See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
or to contribute content related to this error.


> > > > > … … … … … … … … … … Error found:
in module �[33m$PSCI�[0m
at :5:10 - 5:21 (line 5, column 10 - line 5, column 21)

  Unknown value �[33mgenericShow�[0m


See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
or to contribute content related to this error.


> See ya!
()
#+end_example

Per Data.Generic.Rep.Show in pursuit, the package is deprecated.

I looked for the genericShow function and found it in Data.Show.Generic:

Data.Show.Generic
#+begin_src purescript
import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
-- import Data.Generic.Rep.Show (genericShow)
import Effect.Console (logShow)

newtype Score = Score Int

:paste

-- generic deriving prints wrapper with show
derive instance genericScore :: Generic Score _
instance showScore :: Show Score where
  show = genericShow

main = logShow (Score 5)
-- Prints:
-- (Score 5)
#+end_src

#+RESULTS:
: PSCi, version 0.14.0
: Type :? for help
: 
: import Prelude
: 
: > > > > > > > > … … … … … … … … … … > See ya!
: ()

@thomashoneyman thomashoneyman merged commit 3bc7a0e into purescript:master Apr 19, 2021
sevillaarvin added a commit to schfork/documentation that referenced this pull request Apr 20, 2021
Point `Data.Generic.Rep` from the [deprecated link](https://pursuit.purescript.org/packages/purescript-generics-rep/6.1.4/docs/Data.Generic.Rep#t:Generic) to the [new link](https://pursuit.purescript.org/packages/purescript-prelude/5.0.0/docs/Data.Generic.Rep#t:Generic)

Also forgot to change `genericShow` reference from last pull request purescript#385:

```purescript
#+begin_src purescript
import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
-- import Data.Generic.Rep.Show (genericShow)
import Effect.Console (logShow)

:paste

data MyADT
  = Some
  | Arbitrary Int
  | Contents Number String

derive instance genericMyADT :: Generic MyADT _

instance showMyADT :: Show MyADT where
  show = genericShow
  
main = logShow [Some, Arbitrary 1, Contents 2.0 "Three"]
#+end_src

#+RESULTS:
: PSCi, version 0.14.0
: Type :? for help
: 
: import Prelude
: 
: > > > > > > … … … … … … … … … … … … … > See ya!
: ()
```
JordanMartinez pushed a commit that referenced this pull request May 22, 2021
* docs(generic): update Data.Generic.Rep link

Point `Data.Generic.Rep` from the [deprecated link](https://pursuit.purescript.org/packages/purescript-generics-rep/6.1.4/docs/Data.Generic.Rep#t:Generic) to the [new link](https://pursuit.purescript.org/packages/purescript-prelude/5.0.0/docs/Data.Generic.Rep#t:Generic)

Also forgot to change `genericShow` reference from last pull request #385:

```purescript
#+begin_src purescript
import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
-- import Data.Generic.Rep.Show (genericShow)
import Effect.Console (logShow)

:paste

data MyADT
  = Some
  | Arbitrary Int
  | Contents Number String

derive instance genericMyADT :: Generic MyADT _

instance showMyADT :: Show MyADT where
  show = genericShow
  
main = logShow [Some, Arbitrary 1, Contents 2.0 "Three"]
#+end_src

#+RESULTS:
: PSCi, version 0.14.0
: Type :? for help
: 
: import Prelude
: 
: > > > > > > … … … … … … … … … … … … … > See ya!
: ()
```

* Update guides/Type-Class-Deriving.md

Co-authored-by: milesfrain <milesfrain@users.noreply.github.com>

Co-authored-by: milesfrain <milesfrain@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants