Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real World OCaml recommendation #28

Open
1 of 3 tasks
jonahbeckford opened this issue Jan 9, 2023 · 3 comments
Open
1 of 3 tasks

Real World OCaml recommendation #28

jonahbeckford opened this issue Jan 9, 2023 · 3 comments
Assignees

Comments

@jonahbeckford
Copy link
Contributor

jonahbeckford commented Jan 9, 2023

Followups from realworldocaml/book#3657:

  • the seamless base and utop experience is complete
  • documentation updated saying that RWO (only the chapters using base) are good reference material for Windows users.
  • general callout in documentation a) for advanced users only to submit patches to RWO for updates to Windows; there is no chance Diskuv is capable of reviewing everything in that book and b) for beginners that Windows support in RWO is "early" adoption

The net effect will be another great source of learning material for Windows OCaml users.

@avsm
Copy link

avsm commented Mar 23, 2023

I've got a DKML installation running on my Windows box now, so I'm happy to modify the RWO text whenever you're ready, @jonahbeckford. /cc @yminsky.

@jonahbeckford jonahbeckford self-assigned this Mar 24, 2023
@jonahbeckford
Copy link
Contributor Author

Sigh. I lost my window of time to do the action items in the first quarter. Realistically this won't start until May. It is top of the list though.

@jonahbeckford
Copy link
Contributor Author

jonahbeckford commented Jul 8, 2023

Status Update

Jul 23

Jul 7

  • @avsm @nojb Almost finished with the implementation of this. Right now, I am doing testing, and am blocked by small but related important issues.

Set up utop

RWO Page: http://dev.realworldocaml.org/install.html

Proposal: Tweak this section to have a ~/.ocamlinit that works for native Windows users.

Problem 1: The OCaml toplevel does not recognize a user-global .ocamlinit file

I uncovered the following (cross-posted to windows channel in Slack):

Looks like the toplevel has a big omission on native Windows. I'm surprised I didn't encounter this before, but in hindsight I rarely use the toplevel (until now). According to https://v2.ocaml.org/manual/toplevel.html :

On start-up (before the first phrase is read), if the file .ocamlinit exists in the current directory, its contents are read as a sequence of OCaml phrases and executed as per the #use directive described in section 14.2. The evaluation outcode for each phrase are not displayed. If the current directory does not contain an .ocamlinit file, the file XDG_CONFIG_HOME/ocaml/init.ml is looked up according to the XDG base directory specification and used instead (on Windows this is skipped). If that file doesn’t exist then an [.ocamlinit] file in the users’ home directory (determined via environment variable HOME) is used if existing.

Because HOME is not defined in native Windows (or worse, it is defined if you use MSYS2 tooling but that definition is almost always the wrong location to use) ... there is no directory to put .ocamlinit except the current directory.

Mitigation (this won't work):

For now in DkML I'll set XDG_CONFIG_HOME to %APPDATA%, but that is not portable to other (future?) native Windows OCaml systems.

Real Mitigation: Needs a ocaml/ocaml compiler patch.

Problem 2: Ambiguous whether APPDATA or LOCALAPPDATA should be home for .ocamlinit

XDG_CONFIG_HOME has been interpreted inconsistently in the OCaml ecosystem:

The difference is that APPDATA is Roaming, which means if you are in a managed corporate (or educational) environment your .ocamlinit will travel with you.

Mitigation: We just need to pick one ... preferably the one that the OCaml compiler team is comfortable with. I've also opened OCamlPro/directories#15 to get some background on why they chose APPDATA.

Problem 3: .ocamlinit can't be created/edited with Notepad

Without some complicated-for-beginner steps, Notepad will create files that are CRLF line terminated in UTF-16 LE encoding.

That gives:

─────────────────────────┬───────────────────────────────────────────────────────────────────┬──────────────────────────                         │ Welcome to utop version %%VERSION%% (using OCaml version 4.14.0)! │                                                   └───────────────────────────────────────────────────────────────────┘
�[1mFile ".ocamlinit", line 1, characters 0-2�[0m:
1 | ��
    �[1;35m^^�[0m
�[1;35mAlert�[0m deprecated: ISO-Latin1 characters in identifiers
�[1mFile ".ocamlinit", line 1, characters 2-3�[0m:
1 | ��
      �[1;31m^�[0m
�[1;31mError�[0m: Illegal character (\r)

Type #utop_help for help about using utop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants