You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yet another great question/suggestion from @mikeshulman. The library is expecting a file_path in a position, but there's no "file" at interactive prompts. While the internal code is highly modularized and file I/O is isolated, the current external API bundles the file I/O. Here are some concrete fixes I can think of:
Rename Position.file_path to Position.source and make its type polymorphic (so that we will have 'source Span.t). Downsides: too many type variables can reduce usability.
Still rename Position.file_path to Position.source but fix its type to the following:
In either way, a more generic backend which can handle strings from interactive prompts should be made available. This can be as simple as taking yet another optional argument to handle URIs (if we want to allow them).
The text was updated successfully, but these errors were encountered:
favonia
changed the title
🔦 Highlight input strings at an interactive prompt
🔦 No way to highlight input strings at an interactive prompt
Oct 7, 2023
favonia
changed the title
🔦 No way to highlight input strings at an interactive prompt
⌨️ No way to highlight input strings at an interactive prompt
Oct 7, 2023
favonia
changed the title
⌨️ No way to highlight input strings at an interactive prompt
⌨️ No way to generate spans for input strings at an interactive prompt
Oct 7, 2023
Is there a reason to use polymorphic variants here?
My main hesitation consists of two parts:
Having very generic constructors such as File and String might pollute the constructor namespace. OCaml has type-directed disambiguation, which means it will consider all constructors in scope and others indicated by the types (this might not be accurate because I didn't check its algorithm). Polymorphic variants can stop OCaml from insisting on pinning down the "correct" type. I also think that if an implementer (the one who is building the application) wants to declare such generic constructors, so be it. They can pollute their own constructor namespace. But I tend to be more cautious when designing a library (that might pollute the namespace in all the applications using it).
The API should have provided enough helper functions to hide such nasty details in common cases. Perhaps a reasonable design will emerge after we resolve the issue 🧮 Helper functions to recover byte offsets? #88. If this is the case, the burden will be invisible to implementers.
Interesting, thanks. I was not consciously aware of that issue with non-polymorphic variants, although I have been annoyed sometimes at OCaml getting confused when I have constructors in different datatypes with the same name, so maybe I should use polymorphic variants more.
Yet another great question/suggestion from @mikeshulman. The library is expecting a
file_path
in a position, but there's no "file" at interactive prompts. While the internal code is highly modularized and file I/O is isolated, the current external API bundles the file I/O. Here are some concrete fixes I can think of:Position.file_path
toPosition.source
and make its type polymorphic (so that we will have'source Span.t
). Downsides: too many type variables can reduce usability.Position.file_path
toPosition.source
but fix its type to the following:In either way, a more generic backend which can handle strings from interactive prompts should be made available. This can be as simple as taking yet another optional argument to handle URIs (if we want to allow them).
The text was updated successfully, but these errors were encountered: