News for hackers. Stuff that matters.
[dead]
Re:Higher-kinded bounded polymorphism in OCaml by dang on Sunday July 28, 2024 @09:02PM (#41097199)
"Please don't complain about tangential annoyances—e.g. article or website formats, name collisions, or back-button breakage. They're too common to be interesting."

https://news.ycombinator.com/newsguidelines.html

Re:Higher-kinded bounded polymorphism in OCaml by kragen on Monday July 29, 2024 @05:45AM (#41099188)
may be worth mentioning in this case that firefox reader mode (the little cartoon icon of a printed page in the address bar) is helpful. also firefox will remember an increased font size setting for oleg's site if you hit ctrl-+ a few times
Re:Higher-kinded bounded polymorphism in OCaml by skulk on Sunday July 28, 2024 @09:09PM (#41097236)
> Thus, with type aliases, the type equality problem becomes the higher-order unification problem, which is not decidable.

I wonder how much this is a problem in practice, aside from the type-checker taking too long.

Re:Higher-kinded bounded polymorphism in OCaml by nerdponx on Sunday July 28, 2024 @10:02PM (#41097428)
It's tractable in practice. That's what the Idris (2) language does, for example.
Re:Higher-kinded bounded polymorphism in OCaml by dunham on Monday July 29, 2024 @01:36PM (#41102159)
If anyone is interested in how this works, I've found András Kovács' "Elaboration Zoo" to be a good tutorial: https://github.com/AndrasKovacs/elaboration-zoo

It incrementally covers normalization by evaluation, bidirectional typechecking, basic pattern unification, implicit insertion (which relies on unification), and then more sophisticated variants on pattern unification.

Re:Higher-kinded bounded polymorphism in OCaml by munchler on Monday July 29, 2024 @10:14AM (#41100637)
I'm more familiar with F#, so I got stuck at this line:

    type ('a,'b) app += List_name : 'a list -> ('a,list_name) app
I understand that app is an extensible type and this line adds a union case called List_name to the type, but the signature of List_name confuses me. If I write (List_name x) is x a list or a function?
Re:Higher-kinded bounded polymorphism in OCaml by octachron on Monday July 29, 2024 @10:25AM (#41100726)
The variable "x" would be a list in this case. This the GADT (Generalized Abstract Data Types) syntax, where the type of the whole union can depend on the discriminated union case. Thus

      List_name: 'a list -> ('a, list_name) app
reads: for any value "x" of type "'a list", "List_name x" constructs a value of type "('a, list_name) app". In this case, it is the the "list_name" tag part of the type which is dependent on the union case.
Re:Higher-kinded bounded polymorphism in OCaml by munchler on Monday July 29, 2024 @10:28AM (#41100752)
Thank you, that makes sense. Sadly, F# doesn't support GADT's yet.
Re:Higher-kinded bounded polymorphism in OCaml by Neynt on Monday July 29, 2024 @10:26AM (#41100729)
x is a list. This is OCaml’s GADT syntax: https://dev.realworldocaml.org/gadts.html
Re:Higher-kinded bounded polymorphism in OCaml by tempodox on Tuesday July 30, 2024 @01:03PM (#41111472)
This article is pure gold. Rarely is this stuff explained so well.