[Haskell-cafe] FD problem in GHC 6.6

Robert robdockins at fastmail.fm
Tue Dec 19 21:58:30 EST 2006


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.

Are there any easy tricks I can use to make this work? I only sort-of
understand the new restrictions, so I'm at something of a loss as to how
to work around them.

The problem is fairly isolated in my code: the affected section begins
at line 140 in
http://www.eecs.tufts.edu/~rdocki01/shellac/src/System/Console/Shell/Commands.hs


I've reproduced the class and a few of the instance declarations here:




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)
-- 
  Robert
  robdockins at fastmail.fm

-- 
http://www.fastmail.fm - IMAP accessible web-mail



More information about the Haskell-Cafe mailing list