Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.haskell > #298 > unrolled thread

ghci list typeclasses that a type is in

Started byJim Burton <j.burton@brighton.ac.uk>
First post2014-10-24 12:27 +0100
Last post2014-10-24 12:53 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.haskell


Contents

  ghci list typeclasses that a type is in Jim Burton <j.burton@brighton.ac.uk> - 2014-10-24 12:27 +0100
    Re: ghci list typeclasses that a type is in Mark Carroll <mtbc@bcs.org> - 2014-10-24 12:53 +0100

#298 — ghci list typeclasses that a type is in

FromJim Burton <j.burton@brighton.ac.uk>
Date2014-10-24 12:27 +0100
Subjectghci list typeclasses that a type is in
Message-ID<87oat1oghi.fsf@brighton.ac.uk>
Hi, is it possible to use ghci to list all typeclasses that some type is
an instance of? E.g. I can use :info Eq to see all instances of Eq, but
I want to do it the other way round, e.g. :info String...

TIA,

Jim

[toc] | [next] | [standalone]


#299

FromMark Carroll <mtbc@bcs.org>
Date2014-10-24 12:53 +0100
Message-ID<87bnp1k7jf.fsf@ixod.org>
In reply to#298
Jim Burton <j.burton@brighton.ac.uk> writes:

> Hi, is it possible to use ghci to list all typeclasses that some type is
> an instance of? E.g. I can use :info Eq to see all instances of Eq, but
> I want to do it the other way round, e.g. :info String...

It will usually work the other way around: your problem with String is
that it isn't a type in its own right, it's just an alias for a list of
Char:

Prelude> :info Char
data Char = GHC.Types.C# GHC.Prim.Char#         -- Defined in
`GHC.Types'
instance Bounded Char -- Defined in `GHC.Enum'
instance Enum Char -- Defined in `GHC.Enum'
instance Eq Char -- Defined in `GHC.Classes'
instance Ord Char -- Defined in `GHC.Classes'
instance Read Char -- Defined in `GHC.Read'
instance Show Char -- Defined in `GHC.Show'
Prelude> ['a','b','c']
"abc"

-- Mark

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.haskell


csiph-web