Skip to content

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 function length of class Prelude applied to "Hello")

Haskell:

  • Prelude.length("Hello") (function length of module Prelude 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 module Foo)

Proposed dot-noation for function application:

  • foo.bar (function bar applied to foo)
Edited by tepan
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information