infixr 5 .++
I do this in ghci and it gives the error message.
<interactive>:26:10: error:
The fixity signature for ‘.++’ lacks an accompanying binding
How can I fix it? Thank you!
Well like the error says, you indeed defined the fixity, but you still need to define a signature and implementation. Since otherwise, there is actually no operator (or at least we can not use such operator, which is usually why one declares such operator). Since Haskell can derive the signature itself, the signature is strictly speaking not necessary (although it is advisable to write one since it is probably a "top-level function").
For example:
infixr 5 .++
(.++) :: [a] -> [a] -> [a]
(.++) = (++)
Here the second line is the signature, and the third one the implementation. Of course you can pick another signature and implementation.
If you run this in an interpreter, you need to define these all in the same "statement". You can do so by grouping lines, for example with the :{
and :}
commands:
Prelude> :{
Prelude| infixr 5 .++
Prelude| (.++) :: [a] -> [a] -> [a]
Prelude| (.++) = (++)
Prelude| :}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With