[Haskell-cafe] FD problem in GHC 6.6

Robert Dockins robdockins at fastmail.fm
Wed Dec 20 09:36:23 EST 2006


On Dec 19, 2006, at 10:11 PM, Dan Weston wrote:

> > instance CommandFunction (Sh st ()) st where
>                                ^
> I think your first argument (on which the second has a functional  
> dependence) does not determine the second argument, since it makes  
> use of st in the first argument. This strikes me as a likely place  
> to begin.

No, I'm pretty sure this isn't a problem.  The second argument is  
determined _because_ it is mentioned in the first.  The functional  
dependencies and instance declarations work, as long as I can make  
the compiler accept them.  They are only being rejected by the  
termination-checking part of the algorithm.

That said, I'm open to the idea of reformulating these instances.  In  
fact, I don't really like the fact that I need FDs.  It seems to me  
that I should somehow be able to eliminate the second argument  
altogether and thus the FD, but I can't seem to figure it out.

> Dan
>
> Robert wrote:
>> Fellow Haskellers,
>> I have a package that uses some light typeclass hackery to  
>> automaticly
>> build parsing algorithms based on the type of a function.
>> I was recently informed that my package doesn't compile on GHC 6.6  
>> due
>> to the new restrictions on FD resolution; in particular I have  
>> instance
>> declarations which fail the coverage condition.  I can use  
>> undecidable
>> instances to make the package compile again, but I'd prefer not to  
>> if I
>> can avoid it.
>> class CommandFunction f st | f -> st where
>>   parseCommand  :: String -> f -> CommandParser st
>>   commandSyntax :: f -> [Doc]
>> instance CommandFunction (Sh st ()) st where
>
>
>
>>   parseCommand wbc m str =
>>          -- list monad
>>          do (x,[]) <- runRegex (maybeSpaceBefore (Epsilon  
>> (CompleteParse
>>          m))) str
>>             return x
>>   commandSyntax _ = []
>> instance CommandFunction r st
>>       => CommandFunction (Int -> r) st where
>>   parseCommand = doParseCommand Nothing intRegex id
>>   commandSyntax f = text (show intRegex) : commandSyntax (f  
>> undefined)
>> instance CommandFunction r st
>>       => CommandFunction (Integer -> r) st where
>>   parseCommand = doParseCommand Nothing intRegex id
>>   commandSyntax f =  text (show intRegex) : commandSyntax (f  
>> undefined)
>
>



Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
           -- TMBG





More information about the Haskell-Cafe mailing list