augustss / MicroHs

Haskell implemented with combinators
Other
367 stars 25 forks source link

Infix operators don't work #59

Closed ysangkok closed 1 month ago

ysangkok commented 1 month ago

This works:

module Infix where                                                                    

(!) :: [a] -> () -> a                                                               
(!) m k = head m

But this doesn't:

module Infix where

(!) :: [a] -> () -> a
m ! k = head m

The error is:

mhs: error: "Infix.hs": line 4, col 14: Cannot satisfy constraint: ([] ~ (_a23 ->))

It works with ghc-9.6 -c Infix.hs.

MicroHs version is:

$ mhs --version
MicroHs, version 0.10.2.0, combinator file version v7.0

~/MicroHs $ git rev-parse HEAD       
efdc17331aba84555fe9931748138aced8a45a63
augustss commented 1 month ago

Is this just !, or any operator?

ysangkok commented 1 month ago

Ah, right. It's just !. So it might be a clash with the Prelude, I suppose. Seems like GHC 9.6 doesn't have this function in the Prelude somehow.

augustss commented 1 month ago

The problem is that ! needs special hacks since it's also used for BangPatterns. I'll see if I can fix it.

augustss commented 1 month ago

Fixed. Note that

x ! y = ...

and

x !y = ...

do very different things. Haskell lexing is messy. :)