Add :print directive for customizable repl printing - #3478
Conversation
|
I've decided to leave the .purs-repl parsing code alone for now, since I'm not certain I'll be able to update that to handle |
|
Reviewing can probably wait until #3471 is merged, as I'll probably want to rebase this once that has happened. |
dd93308 to
8fa82d3
Compare
| [ImportedModule] | ||
| [P.Declaration] | ||
| [(P.Module, P.ExternsFile)] | ||
| (P.ModuleName, P.Ident) |
There was a problem hiding this comment.
Neither here nor there, but why not use record syntax for this rather than writing hand written selectors?
There was a problem hiding this comment.
I suspect this is the way it is because we don’t want to allow updating the fields directly but we do want to allow reading them. Come to think of it we could do something like declaring this as a record with fields prefixed with an underscore eg _psciImportedModules, and not expose the fields but continue to expose the functions (which only allow reading, not updating).
|
I think the code looks good. In testing it out, the only comment I have is that it might be good to have a way to easily restore the default. I don't think most people would know where the default as. |
|
Being able to reset it does indeed sound sensible. Perhaps the |
|
Actually come to think of it, that might be annoying if you weren’t expecting it to do that. I’ll have a think. |
|
Maybe calling |
|
I think if just |
|
👍 |
Refs #3177. The command > :print MyModule.print will replace the repl's printing function (by default: PSCI.Support.eval) with MyModule.print, if the latter exists and appears to work. The referenced function should have a type of the form forall a. C a => a -> Effect _ i.e., it should accept a wide variety of input types, and return an `Effect T` for some type `T`, whose effects involve printing the argument to the console. The `T` value is discarded. It is not yet possible to configure the repl's printing function from the .purs-repl file.
Entering either `:print` (without arguments) or `:show print` at the repl will now display information about the repl's currently configured printing function. I've also removed the (unused) `hasArgument` function.
a0e6754 to
8491907
Compare
|
I've realised that the existing |
natefaubion
left a comment
There was a problem hiding this comment.
New changes look good!
Refs purescript#3177. The command > :print MyModule.print will replace the repl's printing function (by default: PSCI.Support.eval) with MyModule.print, if the latter exists and appears to work. The referenced function should have a type of the form forall a. C a => a -> Effect _ i.e., it should accept a wide variety of input types, and return an `Effect T` for some type `T`, whose effects involve printing the argument to the console. The `T` value is discarded. It is not yet possible to configure the repl's printing function from the .purs-repl file. Entering either `:print` (without arguments) or `:show print` at the repl will display information about the repl's currently configured printing function. I've also removed the (unused) `hasArgument` function.
Refs #3177. The command
will replace the repl's printing function (by default:
PSCI.Support.eval) with MyModule.print, if the latter exists and appears
to work. The referenced function should have a type of the form
i.e., it should accept a wide variety of input types, and return
an
Effect Tfor some typeT, whose effects involve printing theargument to the console. The
Tvalue is discarded.It is not yet possible to configure the repl's printing function from
the .purs-repl file.