Ben Franksen wrote:
Ryan Ingram wrote:
On 12/5/07, Ben Franksen <[EMAIL PROTECTED]> wrote:
You would have to use functional dependencies or associated types to
eliminate this error. Alternatively, you can add a dummy argument of type
"block" and pass "undefined :: BlockType" in to help choose the instance
declaration.
Sounds reasonable, and in fact that was what I tried first. However
data Command = Skip
class Java block command | command -> block where
block_ :: [command] -> block
compBlock :: [Command] -> block
compBlock = block_ . map compCommand
compCommand :: Command -> command
still gives
Could not deduce (Java block command1)
from the context (Java block command)
arising from use of `block_' at Bla.hs:7:14-19
Possible fix:
add (Java block command1)
to the class or instance method `compBlock'
In the first argument of `(.)', namely `block_'
In the expression: block_ . (map compCommand)
In the definition of `compBlock':
compBlock = block_ . (map compCommand)
which is /exactly/ the same error as I get w/o the fundep.
Yes, because command determines block but block doesn't determine command.
So in a usage of 'compBlock' it has no way of deciding which 'command'
to use, although it can choose the block from the return type.
You could have command -> block, block -> command, if that is indeed true.
Jule
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe