Skip to content

Add File Input Output In OCaml#5975

Merged
rzuckerm merged 3 commits into
TheRenegadeCoder:mainfrom
alope107:ocamlFile
May 18, 2026
Merged

Add File Input Output In OCaml#5975
rzuckerm merged 3 commits into
TheRenegadeCoder:mainfrom
alope107:ocamlFile

Conversation

@alope107
Copy link
Copy Markdown
Contributor

I Am Adding a New Code Snippet in an Existing Language

@github-actions github-actions Bot added enhancement Any code that improves the repo file input output See: https://sampleprograms.io/projects/file-input-output/ labels May 17, 2026
Comment on lines +22 to +23
Out_channel.with_open_text filename (fun oc ->
Out_channel.output_string oc sample_text)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be written 1 line at a time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the way that ocamlformat autoformats the file with the default profile. If you put the lambda on a separate line, it reformats the file back to this. I think for a sample program repository it makes sense to follow the convention set out by the language.

Comment thread archive/o/ocaml/file-input-output.ml Outdated
Comment on lines +3 to +8
(* Some arbitrary interesting text for demo file reading and writing.
These are the 10 thunderwords from Joyce's Finnegans Wake.
See here for a great literary explanation if you're interested:
https://hatterscabinet.com/pages-fw/fwtheme-thunderwords.html *)
let sample_text =
{|bababadalgharaghtakamminarronnkonnbronntonnerronntuonnthunntrovarrhounawnskawntoohoohoordenenthurnuk
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer something a little more mundane than this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, increased mundanity.

@alope107 alope107 requested a review from rzuckerm May 18, 2026 18:43
@rzuckerm rzuckerm merged commit cb6400d into TheRenegadeCoder:main May 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Any code that improves the repo file input output See: https://sampleprograms.io/projects/file-input-output/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add File Input Output in OCaml

3 participants