prelude: input builtin - #19
Merged
Merged
Conversation
Python's input(prompt) name-for-name, the io effect coming in to pair with print's going out; `input "n? " |> String.toInt` is the idiomatic total parse. Monomorphic, seeded next to print; arity rides PRELUDE so lowering and completion need nothing new. DESIGN documents the environment caveats (REPL worker protocol owns stdin; the Pyodide playground cannot block on stdin - pyfun run and Jupyter are the home turf).
Merged
simontreanor
added a commit
that referenced
this pull request
Jul 31, 2026
Two user-visible additions since 0.2.0 -- the `input` prelude builtin
(`string ->{io} string`, #19) and caller-supplied `extern` keyword slots
(`kw = ...`, #21) -- plus five fixes, four of them from the first program
written in Pyfun in anger:
* imported schemes reused the exporting module's type-variable ids, silently
blocking generalization in the importing module and cascading to its
consumers (#26 / #27)
* a recursive function of arity >= 2 could not perform any effect -- the shape
of every loop in a language with no `while` (#24 / #28)
* a module that only matched an imported `Option` emitted `None_` without
importing it (#25 / #29)
* user identifiers collided with Python keywords, builtins the emitter calls,
and modules an `extern` imports (#23 / #30)
* the local-binder module-alias shadowing residual (#18)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
input : string ->{io} stringto the unqualified prelude - Python''sinput(prompt)name-for-name (input ""for promptless), the io effect coming in to pair withprint''s going out.input "n? " |> String.toInt : Option intis the idiomatic total parse, which should make for good lesson material later.One PRELUDE entry + one seeded scheme; arity registration, lowering, and LSP completion all ride the existing PRELUDE table. DESIGN.md documents the environment caveats: the REPL''s worker protocol owns stdin (the already-documented hazard), and the Pyodide playground cannot block on stdin -
pyfun runscripts and Jupyter are the home turf.Tests: typecheck (type, io-effect flow into
let purerejection, prompt must be a string), lowering shape (input("who? ")), an e2e that pipes a real stdin line through the emitted program, and a roundtrip entry. Full suite green; clippy clean.