Open UnkindPartition opened 10 years ago
This sounds like a bug to me, if indeed it works as you say. The intention is that fixities = Nothing
will indeed turn off the fixity resolution altogether, not use the prelude fixities, and that's how it's implemented in InternalParser.ly:
applyFixities' :: (AppFixity a) => Maybe [Fixity] -> a L -> ParseResult (a L)
applyFixities' Nothing ast = return ast
applyFixities' (Just fixs) ast = applyFixities fixs ast
Browsing the code, it appears it will only default to using the prelude fixities if no explicit ParseMode
is given. What case are you seeing?
Ah yes, you're right. But this behavior is even worse than the one I assumed — it means that parseModule
and parseModuleWithMode defaultParseMode
behave differently! No-one would expect that.
Currently the
fixities
field ofParseMode
has typeMaybe [Fixity]
. When it'sNothing
, the fixities fromPrelude
get applied.This is a quick and dirty approach to get things done.
But when used for something serious, it is wrong in many ways.
Ambiguous infix expression
error (see #72)Furthermore, even the idea of supplying complete fixities to the parsing function is wrong:
Thus, for anything serious the
fixities
field ofParseMode
is useless. The correct way to handle fixities is:The problem is, there's currently no way to disable application of fixities. There's a workaround of supplying
fixites = Just []
, but it's not obvious that makesapplyFixities
an identity function, and it would still burn a few CPU cycles, it seems.So, there should be a way of disabling automatic fixity application. In order to stay beginner-friendly and backwards-compatible, it's probably best to introduce a new field to
ParseMode
, something likeapplyFixities :: Bool
, and make itTrue
indefaultParseMode
.