[Haskell-beginners] Re: [Haskell-cafe] Enum and Bounded in generic
type
Derek Elkins
derek.a.elkins at gmail.com
Tue Dec 30 12:22:34 EST 2008
On Tue, 2008-12-30 at 17:12 +0000, raeck at msn.com wrote:
> Hi, how can I make the following code work? (show all the possible values of
> a type 'a')
>
> > showAll :: (Eq a, Bounded a, Enum a) => a -> [a]
> > showAll a = [minBound..maxBound]::[a]
The bottom 'a' has nothing to do with the 'a' in the type signature.
Your code is equivalent to
> > showAll :: (Eq a, Bounded a, Enum a) => a -> [a]
> > showAll a = [minBound..maxBound]::[b]
Which is not type correct as [minBound..maxBound] :: (Bounded a, Enum a) => [a]
You don't need that type annotation (or the type signature for that matter), so just omit it.
More information about the Beginners
mailing list