[Haskell-beginners] It needs a binder?

Dániel Arató exitconsole at gmail.com
Wed Apr 29 08:46:13 UTC 2020


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 at 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 at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200429/e788d571/attachment.html>


More information about the Beginners mailing list