Closed neongreen closed 4 years ago
Look ma, no show
:
> import Prelude (Show)
> show
<interactive>:2:1: error: Variable not in scope: show
Doesn't work:
> data Foo = Foo
> instance Show Foo where show Foo = Foo
<interactive>:3:25: error:
‘show’ is not a (visible) method of class ‘Show’
And now it does!
> import qualified Prelude
> instance Show Foo where show Foo = "Foo"
And show
is still not in scope:
> show
<interactive>:8:1: error:
• Variable not in scope: show
Interesting, I thought it was somewhere in the docs, but apparently it never went beyond Slack discussions.
Since
show
doesn't come fromShow
anymore, you can't writeShow
instances easily.
Looks like a good place (in README) to write how one can do it not easily (but still it looks quite easy).
Btw, we've been doing import qualified Text.Show
which looks a bit better because one can easier realize what this import is for.
May you and your kin prosper for a thousand years
@Martoon-00 did you close it by mistake?
Oh
Btw, we've been doing
import qualified Text.Show
which looks a bit better because one can easier realize what this import is for.
Another reason for it is that if you use base-noprelude
or mixins
to make Prelude
refer to Universum
(or your own custom prelude based on Universum
), import qualified Prelude
probably won't work. When we talk about custom preludes it sometimes might be the case that Prelude
is not Prelude
from base
.
I guess I have spare 10 minutes to do this issue, a PR should come shortly.
:nate: #228
@Martoon-00 did you close it by mistake?
Yep, sorry :/
A workaround I found: if you add
import qualified Prelude
to your module, suddenly you can writeShow
instances as usual.