When you mean to compose functions, it's better to write f . g
than f.g
. It's a little more readable, and you avoid a bunch of problems like this one.
When you have something of the form Foo.bar
or Foo.Bar
in Haskell, it is parsed as a qualified name. That's why Just.f
doesn't work: Just
isn't a module, so the 'interface' for Just
can't be loaded.
Why Just.(+3)
does work as intended: (+3)
is a right section, not an identifier, so the dot can't be part of a qualified name. The only way to interpret it is to assume that .
is an infix application of the operator (.)
, so it must be Just . (+3)
.