[Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?)

Andy Gimblett haskell at gimbo.org.uk
Thu Sep 17 12:01:36 EDT 2009


On 17 Sep 2009, at 16:50, Daniel Fischer wrote:

> Yes, the second appearance of 'constructors' is at an unspecified  
> type.
>
> instance (Enumerated a) => Target a where
>    convert n
>       | n < 0     = Nothing
>       | otherwise = case drop n constructors of
>                        (x:_) -> Just x
>                        _ -> Nothing
>
> would make it compile.

Neat trick.  It works: thanks!

> But there'd be a risk that Target is unusable, depending on how  
> instance resolution is
> done.

Unusable?  How so?  Sorry, but I don't follow...

-Andy



More information about the Haskell-Cafe mailing list