These are chat archives for evhub/coconut

14th
Apr 2018
Evan Hubinger
@evhub
Apr 14 2018 22:38
@ExpHP Interesting idea! Do you if any other languages have syntax for something like that? I'm trying to think about what would be a nice syntax for it.
@eindiran Awesome, looks great! I left a couple of comments but otherwise it looks good.
Michael Lamparski
@ExpHP
Apr 14 2018 22:40
Haskell has an optional feature called "view patterns": https://ghc.haskell.org/trac/ghc/wiki/ViewPatterns, syntax looks like that language's lambdas
if that was done in python parentheses would be required around it to disambiguate from a curried function

I was also thinking it could be something like

def f(pat from expr): ...

though that would use up one of our few, precious remaining keywords

Michael Lamparski
@ExpHP
Apr 14 2018 22:48
To clarify on the view patterns (since that link is a bit dense) it would be something like
oneMore = x -> x + 1

# assigns x = 4
(oneMore -> x) = 3  # maybe parentheses not needed here...

# produces [4, 6, 8]
[1, 2, 3] |> fmap$((oneMore -> x) -> x * x) # parentheses definitely needed here