Unqualified use of Prelude functions for generated main goal
Consider the following Curry module Bug
which defines its own version of the (predefined) (>>=)
operator and also contains an expression that returns a non-()
value within the IO
monad.
(>>=) :: IO a -> (a -> IO b) -> IO b
(>>=) = (Prelude.>>=)
bug :: IO Bool
bug = return True
When I load this program into the REPL and try to evaluate bug
, I get an error message.
Prelude> :load Bug
[1 of 2] Skipping Prelude ( /opt/kics2/kics2-0.6.0/lib/Prelude.curry, /opt/kics2/kics2-0.6.0/lib/.curry/Prelude.fcy )
[2 of 2] Compiling Bug ( Bug.curry, .curry/Bug.fcy )
Bug> bug
[1 of 3] Skipping Prelude ( /opt/kics2/kics2-0.6.0/lib/Prelude.curry, /opt/kics2/kics2-0.6.0/lib/.curry/Prelude.fcy )
[2 of 3] Skipping Bug ( Bug.curry, .curry/Bug.fcy )
[3 of 3] Compiling Curry_Main_Goal ( Curry_Main_Goal.curry, .curry/Curry_Main_Goal.fcy )
Curry_Main_Goal.curry, line 3.23: Error:
Ambiguous variable `>>='
It could refer to:
`Prelude.>>='
`Bug.>>='
kics2c: *** UserException: Illegal source program
Bug>
The bug arises in the function makeMainGoalMonomorphic
defined in src/REPL.curry
. Here, >>= print
is added to the goal above. Since the module Bug
also exports an operation (>>=)
, its use in the generated main goal is ambiguous. Both the (>>=)
operation and the print
function have to be used fully qualified. Thus, Prelude.>>= Prelude.print
should be added instead.