User loginNavigation |
Sectioning a chain of operators and dot as reverse applicationI have a meager syntax proposal and am curious if anyone has explored this design, knows of a language that uses it, or can think of a problem with it. It's comprised of two aspects that work together to support certain idioms in a neighborhood of Haskell syntax. The first aspect is to generalize sectioning of binary operators to chains of binary operators where the first and/or last operand in the chain is missing. Here's a GHCi interaction: Prelude> (1 + 2*) The operator `*' [infixl 7] of a section must have lower precedence than that of the operand, namely `+' [infixl 6] in the section: `1 + 2 *'
So Haskell doesn't like the expression The second aspect is to use dot for reverse application (rather than composition). That is, x.f = f x
Dot and juxtaposition would have equal precedence allowing an OOP-like style (after modifying [1, 2, 3].map (+1).filter (>2) === filter (map [1, 2, 3] (+1)) (>2) In combination with the first aspect, we can recover composition as: f `compose` g = (.g.f) And in general we can capture the tails of OOP-like expressions like this: frob = (.map (+1).filter (>2)) Has anyone used or seen this approach or does anyone see problems with it? By Matt M at 2014-05-07 15:40 | LtU Forum | previous forum topic | next forum topic | other blogs | 6563 reads
|
Browse archives
Active forum topics |
Recent comments
20 weeks 1 day ago
20 weeks 1 day ago
20 weeks 1 day ago
42 weeks 2 days ago
46 weeks 4 days ago
48 weeks 1 day ago
48 weeks 1 day ago
50 weeks 6 days ago
1 year 3 weeks ago
1 year 3 weeks ago