Unpack first-class modules into different module types
Reddit » OCaml
by /u/mister_drgn
8h ago
Suppose I have the following module type X_int = sig val x : int end module type Y_int = sig val y : int end module MyModule = struct let x = 2 let y = 3 end let xmod = (module MyModule : X_int) If I want, I can unpack xmod back into a module of type X_int. match xmod with (module M : X_int) -> M.x But suppose instead I wanted to unpack xmod into a module of type Y_int? Even though the original module was consistent with this type, the following does not work. match xmod with (module M : Y_int) -> M.y I'm wondering if there's any way to get from the first-class module to some m ..read more
Visit website
Dream-html img src from variable
Reddit » OCaml
by /u/TheWholeThing
1d ago
I am pretty new to ocaml (I do have some experience with F# though) and I am experimenting with dream and dream-html to a website. I am having some trouble with setting the image source from a variable. If I use a literal everything works fine e.g. Dream_html.HTML.src "http://website.com/image.jpg" However, if I'm using a variable like so: let img_src = "http://website.com/image.jpg" in Dream_html.HTML.src img_src I get this error that I am having trouble understanding: Error: This expression has type string but an expression was expected of type ('a, unit, string, Dream_html.attr) format ..read more
Visit website
OCaml, Dune on Windows 11
Reddit » OCaml
by /u/lizardturtle
2d ago
Hi, I'm having trouble getting Dune to build projects on my Windows 11 machine. I am simply trying to create a project, build the included Hello World program, and run it. However, when I run dune build I get an error about BUILD_PATH_PREFIX_MAP. I'm not sure what this environmental variable should be set to, but if someone could provide further information I'd be very grateful. You can see what I'm doing in the below screenshot. Thanks! Dune issue with BUILD_PATH_PREFIX_MAP on Windows 11 The funny thing is, I was able to get it to build ONCE. But I forgot how I did it. I think I had to manua ..read more
Visit website
Is the DkML Windows distribution a reasonable choice?
Reddit » OCaml
by /u/InternationalFan9915
2d ago
I need to use ocaml just to do a small college project. Ocaml for backend and Java for frontend. I was doing the ocaml part through WSL and the Java part through Windows, with the intention of compiling ocaml for windows and transferring the .exe to the java folder. It happens that the code compiles but does not execute and the message does not clarify anything. As my time is running out and I don't have time to guess what's wrong, I'm here to ask for advice on whether it would make a difference if I developed everything using Windows or everything using WSL and, if so, which would be more re ..read more
Visit website
Opam trying to find a library in /opt/homebrew
Reddit » OCaml
by /u/peter161803
3d ago
Hello! I'm on my Mac (Sonoma 14.4.1), using Opam (2.1.5). During a normal "opam update/upgrade" cycle, it has recently started to produce the following error: #=== ERROR while compiling dune.3.15.2 ========================================# # context 2.1.5 | macos/arm64 | ocaml.5.1.1 | [https://opam.ocaml.org#2b6e600e](https://opam.ocaml.org#2b6e600e) # path ~/.opam/default/.opam-switch/build/dune.3.15.2 # command ~/.opam/opam-init/hooks/sandbox.sh build ocaml boot/bootstrap.ml -j 9 # exit-code 2 # env-file ~/.opam/log/dune-12667-7bf38e.env # output-file ~/.opam/log/dune-12667-7bf38e.out ..read more
Visit website
Issues with Relationship between Lists to Form a "Dictionary"
Reddit » OCaml
by /u/InternationalFan9915
3d ago
Hello everyone, I'm currently working on a project in OCaml where I need to apply discounts to items based on their categories. I have two lists: one containing the discounts associated with each category, and another containing the items with their respective categories. However, I'm encountering an issue where the discounts are not being correctly applied to the items. When I print the items after applying the discounts, all items show a discount of 0.00, and the discounted price is the same as the original price. Here is the code: open Str open Printf let read_file filename = let lines ..read more
Visit website
Can I manage without .mli files?
Reddit » OCaml
by /u/effinsky
4d ago
Can I control interfaces and expose modules and functions to other files without having .mli files? Honestly, I do not like them and they don't work well with how LSP works right now for OCaml. End of the day, I was going through Serde.ml and found no .mli files... maybe I missed something, but it got me thinking. I can imagine some folks like working with mli but for me omg, it's such a drag to have to toggle files to look up types and update those files often manually. ranting now, so back to the question... Can I manage without .mli files altogether? submitted by /u/effinsky [visit reddit ..read more
Visit website
The OCaml Weekly News for 2024-05-07 is out
Reddit » OCaml
by /u/brabarb
4d ago
submitted by /u/brabarb [visit reddit] [comments ..read more
Visit website
Help with understanding complex currying with List.fold
Reddit » OCaml
by /u/Fit-Replacement7245
4d ago
Hello, I'm trying to understand what this is doing. Every time I go through it i get 16, but it evaluates to 26. Any help understanding would be hugely appreciated. List.fold_left ((fun x y z -> x + (y * z)) 2) 1 [1; 2; 3] submitted by /u/Fit-Replacement7245 [visit reddit] [comments ..read more
Visit website
Does Meta(Facebook) still uses Reason/ReScript/Ocaml in their frontend?
Reddit » OCaml
by /u/GoldStrikeArch
4d ago
I heard sometime ago (maybe 3-4 years ago?) that facebook used some Ocaml dialect (probably ReasonML) in their frontend to generate optimized React. Does they still use it? submitted by /u/GoldStrikeArch [visit reddit] [comments ..read more
Visit website

Follow Reddit » OCaml on FeedSpot

Continue with Google
Continue with Apple
OR