Hello,<br><br><div class="gmail_quote">On Thu, Sep 17, 2009 at 16:05, Daniel Fischer <span dir="ltr"><<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Am Donnerstag 17 September 2009 15:56:03 schrieb José Pedro Magalhães:<br>
<div class="im">> Hey Andy,<br>
><br>
> On Thu, Sep 17, 2009 at 15:40, Andy Gimblett <<a href="mailto:haskell@gimbo.org.uk">haskell@gimbo.org.uk</a>> wrote:<br>
> > Now, some of those algebraic data type types happen to be<br>
> > enumerations; in this case, my idea is to list the constructors, with<br>
> > the rule that each constructor's position in the list is the Int which<br>
> > gets converted into that constructor.<br>
> ><br>
> > > class Enumerated a where<br>
> > > constructors :: [a]<br>
> ><br>
> > E.g. here's a type Bar with three constructors:<br>
> > > data Bar = X | Y | Z deriving (Show)<br>
> > > instance Enumerated Bar where<br>
> > > constructors = [X, Y, Z]<br>
> ><br>
> > (This is certainly ugly. Any suggestions?)<br>
> ><br>
> |constructors| is expressible in SYB:<br>
</div>Wow.<br>
<br>
What about<br>
<br>
data Bar = X | Y | Z deriving (Show, Eq, Ord, Enum, Bounded)<br>
<br>
instance Enumerated Bar where<br>
constructors = [minBound .. maxBound]<br>
<div><div></div><div class="h5"><br>
?<br></div></div></blockquote><div><br>Oh yes, that will certainly work for this very simple datatype. However, one cannot automatically derive instances of |Bounded| for datatypes with non-nullary constructors.<br><br><br>
Cheers,<br>Pedro<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div class="h5">
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>