HNHacker News
TopNewBestAskShowJobs

octachron

314 karma · joined April 29, 2016

submissionscomments
octachron··on OCaml 5.0 Multicore is out
This is fixed now, thanks!
octachron··on OCaml 5.0 Multicore is out
Not for 5.0, the aim of 5.0 was to focus on getting multicore support out of the door. Thus only mingw64 is supported for Windows. Support for MSVC will come with later versions. At the same time, improving opam ecosystem support for Windows is one of the major goal of opam 2.2 . Thus hopefully the support for native Windows will improve in the future (next year?).
octachron··on OCaml 5.0 Multicore is out
The road to multicore OCaml was indeed longer and harder than expected. At the end of the day, the constraint of trying to preserve the behavior of almost all existing programs ended up driving a majority of design choices. Typically, this required at least one major rewrite of the multicore runtime along the way.
octachron··on OCaml 5.0 Multicore is out
The link to the Effect section of the manual at https://v2.ocaml.org/releases/5.0/manual/effects.html works for me and should contain an higher level description of what are effect handlers. Which link was broken for you?
octachron··on OCaml 5.0 Multicore is out
The Christmas presents will be all the issues and bugs that will be discovered between now and Christmas eve in the shiny new multicore runtime.
octachron··on Proofs about Programs
With a constructive logic like the one with Coq, you can use functions as proofs of theorems. Briefly, a function is a constructive proof that you can construct an object of the output type from objects of the input type. This means that you can see types as theorems and functions as proofs of those theorems. But in order to be able to prove useful theorem, you want to enforce that every function does really return an output in all situation.
octachron··on OCaml 5.0 Multicore is out
The type system for algebraic effects is still in the research and design phase at this point.

Right now, I am not even taking a guess of what will be the defining new major features of OCaml 6 (effect system + modular implicits maybe? Maybe not?).

octachron··on Proofs about Programs
This is a common property for proof-oriented languages. Coq shares this property for instance, and you can write an optimizing C compiler in Coq: https://github.com/AbsInt/CompCert .
octachron··on OCaml Canvas
I have heard good things on "OCaml from the very beginning" (available at https://johnwhitington.net/ocamlfromtheverybeginning)
octachron··on OCaml Canvas
The graphics library still exists, it is only distributed as a separate library rather than bundled with the compiler distribution, which seems like a better fit for a pedagogical library like `graphics`. Also `graphics` works fine on Windows. In fact, nowadays the edge-case for `graphics` support is MacOs with its dwindling support for X11.
octachron··on Why OCaml?
Yes, it does. And the new major upcoming version, OCaml 5, even supports parallelism and algebraic effects.
octachron··on OCaml at First Glance
OCaml has nested comments (and comments are also aware of string literals). Thus any fragments of valid OCaml code can be commented without changes. In other words, the whole line below is commented-out.

     (* let x = "*)" (* inner comment *)  *)
octachron··on OCaml Programming: Correct and Efficient and Beautiful
Ok, you are using "parametric polymorphism" to mean bounded polymorphism. This explain my confusion! Indeed, I can understand your point of view then: bounded polymorphism is indeed better done with functors in OCaml. And since functor are syntactically heavy in OCaml there are not used everywhere and only when they are useful. Which doesn't mean that they are not used at all, as the Mirage project can attest. MirageOS is essentially an Operating System build upon OCaml functors.
octachron··on OCaml Programming: Correct and Efficient and Beautiful
Emphasizing the arrow (or in fact the most narrow error) is definitively a good idea in that case. Counting the number of arguments is in general a bit problematic: it is possible to end with an accidental functional value due to an extra argument send to a sufficiently polymorphic function for instance.
octachron··on OCaml Programming: Correct and Efficient and Beautiful
I think that it is better to not forget that expressiveness comes at the cost of a richer world of misbehaving code. If you are used to a world where functions have more than one argument and must be applied to exactly the right number of arguments and nearly never returns another function, starting a curried language suddenly throws you in a situation where many small mistakes like `plus 1` are not caught early anymore. Moreover, those delayed mistake are here to allow room for an expressiveness that you are not using yet. This is a genuinely frustrating situation. And I do hope to improve OCaml type error messages to better highlight type difference at some point in the future.
octachron··on OCaml Programming: Correct and Efficient and Beautiful
> Sorry, but total bullshit.

Ok, locally abstract types are bit weird and historical quirk due to the pre-existing use of type variables as unification type variables. But first, they only matter with GADTs and local modules (a notion that doesn't exist in Haskell). And the good syntax for polymorphic function with GADTs is `type a. a monoid -> a` which requires just one explicit quantification compared to the Haskell variant. So no, Haskell and OCaml type annotations are isomorphic.

> As I specifically called out, all the core data structures are polymorphic.

I took a totally random module from the standard library! Let me another random module after rolling a dice, Atomic. Here only 66% of the functions are polymorphics. Or do you want me to go to another library? Ok, let's go for container, and let's select another random module CCPair: 100% of the functions are polymorphic. Honestly, I struggle to understand how it is possible to conclude that every OCaml library is monomorphic.

What do you mean by LATs? The Haskell wiki doesn't seem to know that term.

> The only polymorphic code that you can write in ocaml without such things are functorial

I am sorry to ask but are you confusing bounded polymorphism with parametric polymorphism?

octachron··on OCaml Programming: Correct and Efficient and Beautiful
You can add a dune-project file at the root of your project with just `(lang dune 3.2)` (or your dune version rather than 3.2). The file can also be generated by "dune init project project_name" for fresh projects.
octachron··on OCaml Programming: Correct and Efficient and Beautiful
Do you have any examples? Unfortunately from my perspective, I cannot make sense of your statements.

OCaml typing is principal in all situation where type inference is decidable. The syntax for annotation for polymorphic functions is isomorphic between OCaml and Haskell.

If I take a random module in the standard library, let's say Array, 95% of the functions in this module are parametric polymorphic. I am thus genuinely puzzled by your statement that "OCaml programmers almost never write polymorphic functions".

octachron··on OCaml Programming: Correct and Efficient and Beautiful
I am not sure which pillar of functional programming is lost with labelled arguments? Partial applications still work, higher-order function too. One might need to use anonymous functions when labels does not match but I don't see any pillar being lost.

In the same way, it is perfectly possible to switch to the imperative style only in the specific code path where performance really matters and use abstraction to isolate this performance-sensitive part from the rest of your application. Ideally, you can then keep both the elegance of functional programming and the performance of imperative programming.

octachron··on OCaml Programming: Correct and Efficient and Beautiful
OCaml does not require more annotations than Haskell for polymorphic functions? Both language only require annotations in the case where inference would be undecidable (polymorphic recursions, higher-rank polymorphism, and GADTs).

I know few cases where OCaml require less annotations than Haskell, I would expect the reverse to be true.

And maps and sets are not the main use case for polymorphism in OCaml. Even taking in account that it sounds like you are talking about functors, maps and sets are still not the only instance of functors in OCaml.

octachron··on OCaml Programming: Correct and Efficient and Beautiful
Concerning the issue with function arguments, this is one of the reason why OCaml has labelled arguments. And for instance, Janestreet's idiom udes labelled arguments as often as possible.

Similarly, I am not sure what is the issue with using imperative OCaml for imperative algorithms when they are a better fit for the problem at hand?

octachron··on OCaml Programming: Correct and Efficient and Beautiful
Parametric polymorphic is the same in OCaml and Haskell. Did you meant to say that the value restriction does not play nicely with point-free programming?
octachron··on OCaml Programming: Correct and Efficient and Beautiful
With OCaml type system permanently burned in my mind, I parse that error message as "there is an ` _ -> Result_set.t ` arrow type which is not compatible with type `Result_set.t`". Do you think that the issue is that the arrow `->` is too hard to spot?
octachron··on OCaml Programming: Correct and Efficient and Beautiful
Do you have a more precise example in mind?

The example that you are describing should emit an error message of the form

    This expression has type type_of_arg_3 -> return_type
    but an expression of   type return_type was expected 
which seem alright to me. (But I cannot not be called an OCaml aficionado). The type error might be delayed in sufficiently polymorphism context but that is a more infrequent occurrence (outside of functors whose error messages have been improved in OCaml 4.13 partially for this reason).
octachron··on OCaml 5.0 Alpha Release
The medium-term plan is indeed to have such a typed effect system. This one of the reason why the effect system is still considered to be experimental: we expect to see some breaking changes once effects become typed.
octachron··on OCaml 5.0 Alpha Release
Essentially, OCaml 5.0 is OCaml 4.14 with a fully rewritten runtime which introduces support for parallelism (no more global runtime lock) and an experimental version of algebraic effects.
octachron··on OCaml 5.0 Alpha Release
The effect system is here, and it can already be used. However, the integration within the (surface) language and its type system is still a work in progress. Thus to explore the use of effects, you need to use the experimental Effect (https://github.com/ocaml/ocaml/blob/trunk/stdlib/effect.mli) module which gives you access to low-level primitives for defining effects, installing an effect handler and resuming a continuation. The module will be considered as experimental in OCaml 5.0 and subsequent version of OCaml 5 will refine the integration within the language. The objective here was to decouple the multicore runtime work from the higher-level language design questions.
octachron··on The Y Combinator in Go with generics
The thing is that you don't want to use directly the Y-combinator, ever.

It is a tool to show that untyped lambda calculus with just anonymous functions and applications is already Turing-complete, because you can write the `Y-combinator`, thus you can define recursive functions, and thus you can write `while` loops.

In a way, the Y-combinator is one of the possible ways to reach Turing-completeness by accident. It is an important example to keep in mind if you want to design a type system for a programming language that is not Turing-complete.

But as soon as you want Turing-completeness, the Y-combinator is not a nice primitive for most users. In this case, either your language is flexible enough to write a good library for recursive definitions based on the Y-combinator. Otherwise, it often works better to introduce recursive definitions as a primitive, even if theoretically this primitive is not absolutely needed.

octachron··on The Y Combinator in Go with generics
The Y-combinator require (equi)recursive types for the intermediary step `x x` where `x` has type `('a -> 'b as 'a) -> 'b` using OCaml notation.
octachron··on Rust Is Hard, Or: The Misery of Mainstream Programming
There is only one OCaml build system (dune) which is used by people that don't write their own build system. But yes, you have the freedom of using alternative to the OCaml standard library if you wish so.
← PreviousPage 2 of 4Next →