r/ocaml • u/[deleted] • Dec 12 '10
r/ocaml • u/Somtimesitbelikethat • May 04 '26
Feeling a bit of dread over AI
Do I even need to learn this language anymore? the current models are so good.
I wanted to learn bc i wanted to be able to audit the code AI would write, but the way Ocaml’s compiler works, it either works or it doesn’t.
help. sorry if this post sounds dense.
r/ocaml • u/[deleted] • Sep 29 '23
We're learning ocaml at uni, 2nd year. I don't understand why people need ocaml. Where is it used? And why the hell recursion 😭
r/ocaml • u/jcgretton • Mar 01 '18
OCAML, Blockchain & Smart Contracts in Paris, France
r/ocaml • u/pmmeifyouwantmee • Sep 08 '19
using recursion to implement for loop, it's so new to me and frustrating.
I'm doing a homework that can be so easily done in java but so hard in ocaml.
r/ocaml • u/ruby_object • Sep 22 '24
Why the command output is in the wrong order?
I have this command output where OCCaml does not seem to wait for the command to finish
$ dune exec lispen
Already up-to-date.
pulled Emacs
--- Emacs -------------------------------
Should I compile Emacs? Please enter your choice Y/n > n
skipped
Already up-to-date.
pulled SBCL
skipping Emacs
--- SBCL -------------------------------
Should I compile SBCL? Please enter your choice Y/n > n
skipped
skipping SBCLThis is the source
let skip name =
let _ = Sys.command "echo 'skipped'" in
Printf.printf "skipping %s" name
;;
let printHeader name = Printf.printf "\n--- %s -------------------------------\n\n" name
let compileEmacs () =
let _ = Sys.command "make; sudo make install" in
Printf.printf "compile Emacs"
;;
let compileSBCL () =
let _ = Sys.command "sh ./distclean.sh; sh ./make.sh; sudo sh ./install.sh" in
Printf.printf "compile SBCL"
;;
let doEmacs () =
printHeader "Emacs";
Sys.chdir "/home/jacek/Programming/emacs-31";
let _ = Sys.command "git pull; echo 'pulled Emacs'" in
Printf.printf "Should I compile Emacs? Please enter your choice Y/n > ";
let rl = Stdlib.read_line () |> String.trim in
if rl = "Y" || rl = "y" then compileEmacs () else skip "Emacs"
;;
let doSbcl () =
printHeader "SBCL";
Sys.chdir "/home/jacek/Programming/sbcl";
let _ = Sys.command "git pull; echo 'pulled SBCL'" in
Printf.printf "Should I compile SBCL? Please enter your choice Y/n > ";
let rl = Stdlib.read_line () |> String.trim in
if rl = "Y" || rl = "y" then compileSBCL () else skip "SBCL";
Printf.printf "\n"
;;
let main () =
doEmacs ();
doSbcl ()
;;
let () = main ()r/ocaml • u/[deleted] • Sep 01 '18
How do I test this Ocaml program and debug it on a mac?
Also is there an easier OS to download and test Ocaml?
r/ocaml • u/sangjoon245 • Mar 18 '20
New to Ocaml!! Really need help on this lambda calculus question/assignment.
Hello.I know posts like these are annoying to deal with and I apologize in advance. But I read pdfs, slides, and went on youtube and none of them seem to pull me into the right direction. I know my basics and all, but for some reason I am stuck still. Not only stuck, but very lost.
So I have to implement Call by Value Reduction (Lambda Calculus) using the following type :
type expr =| Var of string| Lam of string * expr| App of expr * expr
My professor gave us somewhat of a pseudocode to start off with, but so far I have this :
let rec reduce_cbv e =
match e with
| App (e1, e2) -> let (e1', reduced) = (reduce_cbv e1) in
if reduced then (App (e1', e2), true) else let e2', reduced = reduce_cbv e2 in
if reduced then (App (e1, e2'), true) else
match e1 with (* Now since both e1 and e2 are irreducible, we may have a beta redex )
| Lam(x, y) -> match y with ( Yes we indeed have a beta redex )
| App(a1, b1) -> App((substitute b1 x a1), e2), true)
| Lam(x1, y1) ->
| _ ->
| _ -> ... (Now we do have a beta redex.
An example of this is that the input program is "f x" *)Can anyone give me some pointers, what I'm doing incorrectly, etc?Again, sorry in advance.
r/ocaml • u/ry_harper • Dec 22 '17
Surprising uninformed opinions from Facebook engineer
r/ocaml • u/_htmx • May 03 '23
New ocaml user demonym just dropped
'ocamlamadingdong'
https://twitter.com/htmx_org/status/1653764936059822082
(seriously, htmx ❤️ ocaml, there are some folks doing some really neat stuff w/ this combo)
r/ocaml • u/GeoPenguin • Sep 09 '24
I need help in downloading OCaml on my windows machine. ocaml-base-compiler failed to build.

Once I had attempted to download Ocaml using the winget command as per the documentation. I continually get this error. I have tried to run with limited job parallelism (jobs =1 *not the exact command) however it all ends the same. I was hoping for a surefire way to fix this installation error or for a proven method of clearing my computer of any trace of opam/OCaml and starting from square one. I believe my issue to be related to (Error building ocaml-base-compiler.5.2.0 on x86_64 windows · Issue #26206 · ocaml/opam-repository · GitHub) however I am unsure of what exactly was going on here. I too can run my commands again using --verbose if necessary. Unfortunately, with me being a beginner I am a bit more helpless than I would personally like to be. This all started from a failure in downloading the 'ocamlformat' package and I have attempted to manually remove every trace of opam/OCaml, but the end result is the same.
r/ocaml • u/PurpleUpbeat2820 • Jul 14 '22
F# (in)compatibility
I'm just playing with F# coming from an OCaml background. There's lots of cool stuff in both languages but I cannot help but wonder why so many functions common to both languages have different names.
F# OCaml
Seq.tryPick Seq.find_map
Seq.truncate Seq.take
Seq.skip Seq.drop
Seq.skipWhile Seq.drop_while
Seq.cache Seq.memoize
Seq.collect Seq.concat_map or Seq.flat_map
Seq.fold Seq.fold_left
Seq.choose Seq.filter_mapWhy is this?
r/ocaml • u/synkit • Oct 07 '25
LLM Code Generation for OCaml
Curious how folks' experience with using Cursor/Claude Code/pick your favorite agent for OCaml projects compares to other languages? I would guess that it's materially worse than JS/Python just based on volume of available data, but maybe there are type system or other guide rails that end up giving agents better context in an agentic setting? Fairly subjective question, just curious about anecdotal experience. OCaml beginner here.
r/ocaml • u/PacinoPacino • Jun 09 '19
CYK Algorithm in Ocaml
Hey guys so i need to implement a CYK Algorithm in ocaml (to see if a string belongs to a certain grammar) but i'm a bit of a newb and i'd like to hear some tips on how to proceed
r/ocaml • u/bear007 • Jan 10 '23
OCaml 5 Is The Language Of The Future
r/ocaml • u/PurpleUpbeat2820 • Nov 23 '24
LLMs and OCaml
I find there is surprisingly little interest in LLMs here which I think is a shame because with a little fine-tuning they could be really good at OCaml.
I've been using mostly qwen2.5-coder:32b-instruct-q4_K_M for OCaml and it is remarkably good. I just ported a web scraper from a RPi to a Mac and hit:
Fatal error: exception Unix.Unix_error(Unix.EINVAL, "select", "")The AI diagnosed the problem right away and told me to replace this:
Lwt_io.read_lines Lwt_io.stdin
|> Lwt_stream.iter_p process_url
|> Lwt_main.runwith this:
let max_concurrent = 30 in
let pool = Lwt_pool.create max_concurrent (fun () -> Lwt.return_unit) in
Lwt_io.read_lines Lwt_io.stdin
|> Lwt_stream.iter_p (fun line -> Lwt_pool.use pool (fun () -> process_url line))
|> Lwt_main.runwhich worked!
r/ocaml • u/Tomus • Apr 24 '21
/r/rescript - A sub for the ReScript programming language
reddit.comr/ocaml • u/InternationalFan9915 • May 02 '24
Newbie problem
A few days ago I posted about having to learn Ocaml to do a college assignment. The assignment involves creating a shopping cart system with Ocaml for the backend and Java for the frontend. The professor provided a database "store.pl" and a file "main.ml" that reads this file and returns the following (in "interpreter mode"/ocaml):
# #use "main.ml";;
val read_file : string -> string list = <fun>
val parse_discount : string -> (string * float) option = <fun>
val parse_item : string -> (int * string * string * float * int) option =
<fun>
val parse_loyalty_discount : string -> (string * float) option = <fun>
val parse_shipping_cost : string -> (string * float) option = <fun>
Discount for category 'potions': 0.100000
Discount for category 'wands': 0.200000
Discount for category 'enchanted_books': 0.300000
Discount for category 'crystals': 0.150000
Discount for category 'amulets': 0.250000
Item: 1, Potion of Healing, potions, 10.000000, 50
Item: 2, Wand of Fireball, wands, 20.000000, 30
Item: 3, Enchanted Spellbook, enchanted_books, 30.000000, 20
Item: 4, Crystal of Clairvoyance, crystals, 15.000000, 40
Item: 5, Amulet of Protection, amulets, 25.000000, 25
Loyalty discount for 1 year(s): 0.050000
Loyalty discount for 2 year(s): 0.100000
Loyalty discount for 3 year(s): 0.150000
Loyalty discount for 4 year(s): 0.200000
Loyalty discount for 5 year(s): 0.250000
Loyalty discount for >5 year(s): 0.300000
Shipping cost to district Aveiro: 5.000000
Shipping cost to district Lisboa: 7.000000
Shipping cost to district Porto: 10.000000Alright, so I started by creating a file "app.ml" and I would need to receive this list in a variable to then manipulate the strings and so on. The thing is, I couldn't even get past the third line because I don't know how to receive this list.
I have something like:
open Main
let dados = Main() ?????;How should I go about it?
P.S.: Another question: can I test this code, divided into several files, through the interpreter or do I need to compile it??
Thanks for your attention!
