google-research/dex-lang

Add syntax for "the previous value"

Open

#1.144 aberto em 4 de nov. de 2022

Ver no GitHub
 (6 comments) (0 reactions) (0 assignees)Haskell (116 forks)batch import
good first issuelanguage / concrete syntaxshovel-ready

Métricas do repositório

Stars
 (1.681 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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!

Guia do colaborador