reset password
Author Message
wsakura
Posts: 64
Posted 23:54 Aug 25, 2017 |

Hello,

I'd like to ask if anyone was able to run this code:

...

trace :: String -> a -> a
primes = 2 : [trace (show p ++ " is prime.") p |
                                        p <- oddsFrom3,
                                        trace (show p)
                                              (null (primeDivisors p))]

It was given in the project description. I have been getting the error:

The type signature for `trace' lacks an accompanying binding

I've been googling around, but I still don't understand what this means. Would anyone be able to elaborate?

Thank you!

rabbott
Posts: 1649
Posted 09:10 Aug 26, 2017 |

The problem is the trace declaration. The trace function is already defined. By writing a declaration, you are telling the compiler that you intend to define another version of it. The compiler now expects to see your definition of trace. The diagnostic says that it can't find it.

wsakura
Posts: 64
Posted 18:06 Aug 26, 2017 |
rabbott wrote:

The problem is the trace declaration. The trace function is already defined. By writing a declaration, you are telling the compiler that you intend to define another version of it. The compiler now expects to see your definition of trace. The diagnostic says that it can't find it.

Thank you Dr. Abbott!