Am Samstag 19 September 2009 20:55:10 schrieb Andy Gimblett:
> On 17 Sep 2009, at 18:01, Ryan Ingram wrote:
> > Here's a way that works more closely to your original version:
> >
> > instance Enumerated a => Target a where
> >    convert n
> >
> >        | n >= 0 && n < numConstrs = Just (constrs !! n)
> >        | otherwise = Nothing
> >
> >     where
> >        constrs = constructors
> >        numConstrs = length constrs
>
> Aha - that's great, and it works without OverlappingInstances (but
> still with FlexibleInstances and UndecidableInstances - should that
> worry me?)

FlexibleInstances need not worry anybody. They just remove a fairly arbitrary 
restriction 
of Haskell98 for instance declarations.

UndecidableInstances can be dangerous, but there are perfectly safe things 
which reauire 
UndecidableInstances, too.

>
> Just making sure constructors is only referenced once is the key, it
> seems.

Just making sure that every time it is referenced, it is referenced at the 
correct type.

>
> Thanks!
>
> -Andy

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to