Dot-Notation for Flipped Function Application
Please allow to put a dot .
(without whitespaces) between two things for flipped function application. This could make for code in pseudo-OOP style:
encrypt(str) = do {
str.map(succ);
}
Currently, as a workaround, this can be achieved by defining (.) = flip ($)
(making .
for function composition unavailable, though):
encrypt(str) = do {
str.map(succ);
} where (.) = flip ($)
(For a remotely similar look-and-feel, one could use Data.Function.((&))
instead of (.)
.)
Side note: .
without whitespaces is already an OOP-like notational convenience in order to denote Modules and their elements in Haskell.
OOP:
-
Prelude.length("Hello")
(static functionlength
of classPrelude
applied to"Hello"
)
Haskell:
-
Prelude.length("Hello")
(functionlength
of modulePrelude
applied to"Hello"
)
This means, that a distinction between .
(with whitespaces) and .
(without whitespaces) is already been made, which is why Just . Just $ 42
compiles, whereas Just.Just $ 42
doesn't. Analogously, with this Feature Request implemented, "Hello".map(succ)
would compile whereas "Hello" . map(succ)"
wouldn't.
Current dot-notation for modules (not to be changed):
-
Foo.bar
(bar
of moduleFoo
)
Proposed dot-noation for function application:
-
foo.bar
(functionbar
applied tofoo
)