exercism / ocaml

Exercism exercises in OCaml.
https://exercism.org/tracks/ocaml
MIT License
93 stars 50 forks source link

Base Library usage #433

Open idkjs opened 2 years ago

idkjs commented 2 years ago

Hey folks,

First thanks for this excellent project and congratulations on the new v3. It is certainly much cleaner looking with more detailed instructions. Should be easier for people to get into though it wasnt that hard to begin with.

I have come back to this after a while and am only now noticing the use of Janestreet's Base library. Might have been there before.

Even though I have been starring at code in the ocaml ecosystem for a while, I have never really used base.

I wanted to suggest maybe make some projects that teach/demonstrate using Base that would target the type of beginner user you can expect.

For example, unwinding a result of a function out of Base.Result.t is really undoable if you dont have a clue.

Maybe we can add some language to the Readme's with examples about what that is or looks like.

I am not sure if this is an issue or suggestion that would be better presented somewhere else. Let me know.

Peace/Love and thank you, again.

tautologico commented 1 year ago

I think all exercises should be solvable without Base, as many people in the community prefer not to use it. There are some exercises where this is currently impossible, but they could be fixed.

nrolland commented 1 year ago

the make test_generatorstep still refers to base and a few other library. It would be worthwhile to either take them out of the tests, or add them to the dependencies list of make install_deps

georgyo commented 1 year ago

Unless anyone objects strongly, I am going to close this issue in a week.

I agree that all the problems should be solvable without base, and I think issues about those specific problems could be tickets. But as it stands now I don't think I've come across one that wasn't solvable without using base.

In ocaml a type can be made to the same as other types, and base does a pretty good job of this. IE Base.Result.t and Result.t are interchangeable. Even if the tests and mli are using Base.Result.t the implementation can still not use Base at all.

@nrolland I don't think anyone noticed the missing dependencies in make install_deps because the both the test runner and this github action to test this repo don't use that function. Those docker files call opam install directly. IE: https://github.com/exercism/ocaml/blob/a0afba8027337a045856bdb255c51500d414d74a/.github/Dockerfile#L14-L15

I'll create a PR to fix that up.

Lattay commented 10 months ago

The exercise count_nucleotide uses a Base.Map as it output type, which makes it impossible to solve the exercise without Base. Unfortunately, the fact that Base is opened by default causes confusion (in particular with =). Also Base.Map appears to be very confusing to students, as I have seen while mentoring. I have seen several students trying to do crazy applicative functor stuff when they are way to early in their learning process, just because the doc of Base.Map is confusing. I think at least that exercise should be reworked to use something more generic as an output, maybe simply a function.

nkhlmn commented 8 months ago

I am new to OCaml and had the exact experience described by @Lattay . I actually abandoned exercism as a learning resource after being confused by count_nucleotide and started using AoC for practice. Now that I am over the hump (pun very much intended), it makes sense to me why I was confused and I have more context about Core, Base and whatnot.

I'm really liking OCaml but I think my biggest complaint (asides from lack of easy pretty printing; though utop makes up for that) is the split between using the standard library vs Jane Streets'. I think it would be a dramatically better experience for people learning to avoid this issue at the beginning.

I'd be happy to submit a PR for count_nucleotide and any others I come across if they would be accepted. Even using a Map is maybe not necessary for an early exercise when an associatian list would also do the trick (and IMO better to learn first).