lacks an accompanying binding - What does it mean? How it works?

Optimight picture Optimight · Jul 27, 2012 · Viewed 24.4k times · Source

I am practising from LYAH.

phoneBook.hs file contains following code:

phoneBook :: [(String, String)]

While trying to compile the above-mentioned code I am getting following error:

*Main> :load "/home/optimight/phoneBook.hs" [1 of 1] Compiling Main ( /home/optimight/phoneBook.hs, interpreted )

/home/optimight/phoneBook.hs:1:1: The type signature for `phoneBook' lacks an accompanying binding Failed, modules loaded: none.

Question added after brano's answer and subsequent comment to this answer: How do we provide implementation for above-mentioned type signature?

If I add this :

type phoneBook = [(String, String)]

I am getting following error:

Prelude> :load "/home/optimight/phoneBook.hs" [1 of 1] Compiling Main ( /home/optimight/phoneBook.hs, interpreted )

/home/optimight/phoneBook.hs:2:6: Malformed head of type or class declaration: phoneBook Failed, modules loaded: none

Answer

brano picture brano · Jul 27, 2012

You need to provide an implementation for phoneBook.

phoneBook :: [(String, String)] is just the signature.