[Haskell-cafe] Printing list of enum type

michael rice nowgate at yahoo.com
Tue Apr 14 10:30:06 EDT 2009


Dumb, dumb, dumb, dumb, DUMB!, he Lisped.

Thanks.

Michael

--- On Tue, 4/14/09, Andrew Wagner <wagner.andrew at gmail.com> wrote:

From: Andrew Wagner <wagner.andrew at gmail.com>
Subject: Re: [Haskell-cafe] Printing list of enum type
To: "michael rice" <nowgate at yahoo.com>
Cc: haskell-cafe at haskell.org
Date: Tuesday, April 14, 2009, 9:19 AM

You don't need to add anything, you just need to use list notation correctly. Try typing [Red, Black, White] in at the prompt instead. The commas are part of the list syntax.

On Tue, Apr 14, 2009 at 9:15 AM, michael rice <nowgate at yahoo.com> wrote:

What do I need to add to this Color enum type to print a list of them?


Michael

===============


data Color

    = Red

    | Blue

    | Green

    | Yellow

    | Orange

    | Brown

    | White

    | Black



instance Show Color where

    show Red   = "Red"

    show Blue  = "Blue"

    show Green = "Green"

    show Yellow = "Yellow"

    show Orange = "Orange"

    show Brown = "Brown"

    show White = "White"

    show Black = "Black"

======================


Ok, modules loaded: Main.
*Main> Red
Red
*Main> Black
Black
*Main> [Red Black White]

<interactive>:1:1:
    Couldn't match expected type `Color -> Color -> t'
           against inferred type `Color'

    In the expression: Red Black White
    In the expression: [Red Black White]
    In the definition of `it': it = [Red Black White]










      
_______________________________________________

Haskell-Cafe mailing list

Haskell-Cafe at haskell.org

http://www.haskell.org/mailman/listinfo/haskell-cafe







      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/b1dba852/attachment.htm


More information about the Haskell-Cafe mailing list