google-research/dex-lang

Add syntax for "the previous value"

Open

#1144 aperta il 4 nov 2022

Vedi su GitHub
 (6 commenti) (0 reazioni) (0 assegnatari)Haskell (116 fork)batch import
good first issuelanguage / concrete syntaxshovel-ready

Metriche repository

Star
 (1681 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

With @dougalm.

A use-case is when binding a large expression to a name, e.g.

x = case stuff of
  A -> ...
  B -> ...
  C -> ...
  ...
<x only enters scope down here>

Perhaps it would be nicer to write

case stuff of
  A -> ...
  B -> ...
  C -> ...
  ...
x =^

where =^ is a new lexeme meaning "bind to the previous value in the block". There is also precedent in other languages, especially at a REPL, for a magic identifier that means "the previous value".

Reactions? Discuss!

Guida contributor