Define infix operator <$?> (chapter 4)

Just reading through the PS book and was trying to define the <$?> operator for filter

Within the PSCi repl

> infix 4 filter as <$?>
Unexpected token 'infix' at line 1, column 1

Why can’t I use the infix keyword? (note this is the solution from the book it’s self)

You have stumbled upon the same “issue” as this guy, ie you can’t use infix in the repl. It’s perfectly fine to load a file with a infix-definition in the repl though.

Thanks for the clarification!

I started to suspect such a constraint however being unfamiliar with PS I wasn’t sure. This makes me feel much better.

Thanks for the feedback and troubleshooting assistance.

Just added a note for that exercise in this PR (updated section), so hopefully future readers are spared from this common source of confusion.

There’s no reason I can think of that you shouldn’t be able to define an infix operator in the repl, incidentally, so I think this is probably just an oversight. To anyone who is reading and might be interested: please feel free to open an issue and/or submit a PR to the compiler :slight_smile:

1 Like

Created https://github.com/purescript/purescript/issues/3978

2 Likes