hmemcpy / milewski-ctfp-pdf

Bartosz Milewski's 'Category Theory for Programmers' unofficial PDF and LaTeX source
https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
Other
10.88k stars 578 forks source link

OCaml version of CTFP #201

Closed ArulselvanMadhavan closed 4 years ago

ArulselvanMadhavan commented 5 years ago

The snippets are pulled from this repo(currently using a semi-automatic way): https://github.com/ArulselvanMadhavan/ocaml-ctfp

@hmemcpy When you get a chance can you review and let me know if everything looks good. cc: @mseri @XVilka

Added chapters:

To see the completed version of the PDF

make ocaml

Please submit your corrections to the original branch, since I don't look at this PR often

ArulselvanMadhavan commented 5 years ago

@hmemcpy Part 1 of the book is now done. I will be starting work on Part 2 of the book soon.

ArulselvanMadhavan commented 4 years ago

@mseri Chapter 11 and Chapter 12 are ready for review. Now you can review the snippets by generating the pdf and reading the text that provides the context to it.

make ocaml
hmemcpy commented 4 years ago

Great job! Keep it going :)

ArulselvanMadhavan commented 4 years ago

@mseri Chapter 13 is ready for review, when you have some time...

mseri commented 4 years ago

Thanks! Chapter 13 looks fine as it is

ArulselvanMadhavan commented 4 years ago

@mseri Chapter 14 is ready for review. Thanks

XVilka commented 4 years ago

@ArulselvanMadhavan can you please also resolve the src/Makefile conflict?

ArulselvanMadhavan commented 4 years ago

@XVilka Resolved the conflicts. Let me know if you're not able to generate the pdf.

ArulselvanMadhavan commented 4 years ago

@mseri Chapter 15 is ready for review. Thanks!

mseri commented 4 years ago

Chapter 15 looks good. We should find a way to deal with ocaml “verbosity” in the compiled book. Many lines are too long or truncated in a weird way

ArulselvanMadhavan commented 4 years ago

@mseri Chapter 16 is now ready for review. This also marks the completion of Part 2 of the book. Re: Your suggestion on formatting the snippets. I'm thinking about using ocamlformat. Do you have a sample repo that I can look at? I haven't looked into it that much. I just know that it exists.

Thanks!

mseri commented 4 years ago

I had a suggestion for Ch16, a PR is already on your repo.

For ocamlformat, you need to produce a .ocamlformat file with your configuration (I use https://github.com/owlbarn/owl_ode/blob/master/.ocamlformat), add (using fmt 1.1) to your dune-project file, and then run dune build @fmt --auto-promote to update all the snippets (I hope it works with your current workflow, but I don't immediately see why not).

ArulselvanMadhavan commented 4 years ago

@mseri Chapter 18 is ready for review. Snippet06.ml got really long mainly because I was trying to get compiled code that shows the equivalence between unit/counit and left_adjunct/right_adjunct. Let me know if it feels like too much information to the reader and then I will resort to simpler version.

Thanks!

mseri commented 4 years ago

I have sent a small PR but looks good

ArulselvanMadhavan commented 4 years ago

@mseri Chapters 19 and 20 are ready for review, when you have some time. Chapter 20 has quite a lot of snippets and I had to upgrade compiler to 4.08.1 to get the let* bindings to work.

mseri commented 4 years ago

I had a brief look. I think chapter 20 need some changes, PR and comments are on the repo

jbulow commented 4 years ago

Is there a pre-built pdf to be downloaded somewhere?

ArulselvanMadhavan commented 4 years ago

@jbulow To be consistent with the base repo, I haven't checked in the pdf file. But you should be able to generate one by checking out the branch and running make ocaml

ArulselvanMadhavan commented 4 years ago

Hi @mseri, Chapter 21 is ready for review. It has quite a lot of snippets but they were simple.

jbulow commented 4 years ago

@jbulow To be consistent with the base repo, I haven't checked in the pdf file. But you should be able to generate one by checking out the branch and running make ocaml

Where do I find the branch to checkout?

ArulselvanMadhavan commented 4 years ago

@jbulow Oh, It's the branch from which this PR is made. Here's the link - https://github.com/ArulselvanMadhavan/milewski-ctfp-pdf/tree/ocaml?files=1

jbulow commented 4 years ago

@jbulow Oh, It's the branch from which this PR is made. Here's the link - https://github.com/ArulselvanMadhavan/milewski-ctfp-pdf/tree/ocaml?files=1

Thanks!

The next step is to find the requirements to build the pdf. A full texlive installation does not seem to be enough:

! Package fontspec Error: The font "Inconsolata LGC" cannot be found.

jbulow commented 4 years ago

@jbulow Oh, It's the branch from which this PR is made. Here's the link - https://github.com/ArulselvanMadhavan/milewski-ctfp-pdf/tree/ocaml?files=1

Thanks!

The next step is to find the requirements to build the pdf. A full texlive installation does not seem to be enough:

! Package fontspec Error: The font "Inconsolata LGC" cannot be found.

I found the missing fonts here:

inconsolata-lgc

libertinus-math

jbulow commented 4 years ago

The pdf builds but the build ends with:

Chapter 22. (./content/3.6/monads-categorically.tex [362] [363] [364] (./_minted-ctfp-reader-ocaml/991E021E8D4F02BF29CCA18F8D81B02E5E10569AA78F25D735 249D93B94B8D68.pygtex)Error: cannot read infile: [Errno 2] No such file or directory: 'ctfp-reader-ocaml.pyg' system returned with code 256

hmemcpy commented 4 years ago

There's a nix-shell environment that downloads all prerequisites for building the book, so you don't have to! Install nix and type nix-shell at the project root directory. After nix downloads the entire internet, you'll get a shell where you can run the makefile, and everything should Just Work™

ArulselvanMadhavan commented 4 years ago

@mseri 👋 Chapter22 is ready for review, when you have some time

mseri commented 4 years ago

Looks good!

ArulselvanMadhavan commented 4 years ago

@mseri 👋 Chapter 23 is ready for review and it has quite a lot of snippets. Also, I'd like hear your thoughts on (if/how) we can define ComonadImplViaExtend and ComonadImplViaDuplicate using recursive modules.

XVilka commented 4 years ago

Only a few chapters with the actual code left (27th is the last one with the code). Amazing work! 💯

ArulselvanMadhavan commented 4 years ago

@mseri Chapter 24 is also ready for review. Enjoy your holidays, and when you are back, and find some time, let me know how it looks. Thanks!

ArulselvanMadhavan commented 4 years ago

@mseri Happy New Year 2020! Chapter 25 is now ready for review.

hmemcpy commented 4 years ago

Just wanted to congratulate you again on the fantastic job! Thank you so much! Looks great!

There are some snippets that will have to be adjusted for width, but we can deal with it later! image

In the meantime, please rebase on top of master, so the build issues are fixed.

hmemcpy commented 4 years ago

Hmm, also I need to fix the half-title page, I'm using \titlecap to convert the OPTCustomLanguage name to Title case, but it obviously doesn't work for OCaml... perhaps I'll just add another field with the "display name" of the language.

ArulselvanMadhavan commented 4 years ago

@hmemcpy Rebased. Also, I'd like to run an idea by you. I have been thinking of the potential corrections to snippets in the book. Right now, we are maintaining the scripts in two places.

  1. In here: https://github.com/ArulselvanMadhavan/ocaml-ctfp
  2. I generate snippets from there and place them in the fork of this repo

If we accept corrections to the completed version of the book in one of the two repos, the other will be outdated. This also applies to minor changes like formatting to limit the width.

I'm thinking of writing a script that downloads and uses the snippets during the pdf generation and removes them when it's done, so the snippets are in one place? Just a thought. I am open to other ideas as well.

ArulselvanMadhavan commented 4 years ago

Hey @mseri , Just wanted to let you know that Chapter 26 is also ready for review.

mseri commented 4 years ago

Sorry, for the long silence. I hope I will have time to see all the chapters in a couple of weeks time

ArulselvanMadhavan commented 4 years ago

No worries @mseri ! Take your time. I added the snippets for the final two chapters. So, now everyone should be able to build the full book with the OCaml version. I will wait for you to review the snippets before trying to get this merged.

cc: @XVilka @hmemcpy

mseri commented 4 years ago

Added my comments. Thanks for the nice work!

anton-trunov commented 4 years ago

@ArulselvanMadhavan Awesome work! I took a quick look and it seems the snippets could benefit from running a formatter (e.g. ocamlformat) on them. There are quite a few places with inconsistent use of whitespace, e.g. x:int vs x : int and so on. I could give you a hand with that if you think it's worth doing it.

ArulselvanMadhavan commented 4 years ago

@ddickstein @anton-trunov Yes. I do plan to run ocamlformat on the snippets that cut off from the page after I merge @mseri 's changes

XVilka commented 4 years ago

I guess it's not WIP anymore then and ready for the review?

mseri commented 4 years ago

Indeed. And chapter 24 would benefit from more eyes

ArulselvanMadhavan commented 4 years ago

@mseri Yeah, I plan to make a post with the Fix point examples from the book to OCaml forums when I find some time

hmemcpy commented 4 years ago

This is fantastic, @ArulselvanMadhavan and everyone! Thank you for your efforts!

I would like to fix the half-title page, so it doesn't display Ocaml, and when it's all reviewed would be proud to press the merge button!

hmemcpy commented 4 years ago

I finally had some time to rework the caches and some tweaks in the Makefile, hopefully it won't break much. @ArulselvanMadhavan can you give me push access to your fork? I'll send my fixes directly to the branch.

ArulselvanMadhavan commented 4 years ago

@hmemcpy I added you as a collaborator. You should be able to send the fixes, now. Thanks!

hmemcpy commented 4 years ago

Alright! I'm ready to push the big button! Let's fix minor issues once it's on.

Thank you again very much for this valiant effort!

mseri commented 4 years ago

@ArulselvanMadhavan have you seen this? https://discuss.ocaml.org/t/attempting-to-create-recursion-schemes-in-ocaml/5144/2

ArulselvanMadhavan commented 4 years ago

@mseri No, I haven't. Thanks for bringing it to my attention! I will have a look