Using classic C/C++/Java terms what you're doing in the first version is analogous to _declaring_ a function but not _defining_ it, e.g.

// binding_incorrect.c
int i();
// No definition leads to an error

// binding_correct.c
int i() {
    return 0;
}

The error message says that you have declared the type of i to be Num a => a, but no corresponding definition was found. That's the reason your second version compiles fine

On Tue, 28 Apr 2020 at 21:22, Alexander Chen <alexander@chenjia.nl> wrote:
Hi,

binder.hs

i:: Num a => a

prelude>:l binder.hs
typed_checked.hs:1:1: error:
    The type signature for ‘i’ lacks an accompanying binding
  |
1 | i:: Num a=> a   | ^


binder.hs

i:: Num a => a
i = 2

prelude>:l binder.hs
[1 of 1] Compiling Main             
Ok, one module loaded.


Why does it need a binder to make it work?



_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners