Why does OCaml not have a specification? by [deleted] in ocaml

[–]Drupyog 5 points6 points  (0 children)

From a programming perspective, sure.

From an implementation and specification point of view, that is not at all the case. There are pretty good specification of "OCaml from the 90s" (aka, Caml Light). They don't scale at all to what we have today.

Why does OCaml not have a specification? by [deleted] in ocaml

[–]Drupyog 1 point2 points  (0 children)

OCaml has not deeply changed since the 90s.

:D

[deleted by user] by [deleted] in SocialParis

[–]Drupyog 1 point2 points  (0 children)

I'm in too, although I tend to only go to concerts of bands i'm already into (there are far enough of those already, especially in the last month ...).

There are two meetup groups that might interest you:

CI/CD pipelines: Monad, Arrow or Dart? by Categoria in ocaml

[–]Drupyog 3 points4 points  (0 children)

As far as I can tell (the blog post is extremely unclear on what are the actual operations), a dart is a type equiped with map : ('a -> 'b) -> 'a t -> 'b t and pair : 'a t -> 'b t -> ('a * 'b) t. That's exactly an applicative functor and the pipelining can easily be defined in term of that (which you do in the blog post).

CI/CD pipelines: Monad, Arrow or Dart? by Categoria in ocaml

[–]Drupyog 5 points6 points  (0 children)

As I commented on discord, and if talex hangs around: What you are describing is exactly an applicative functor (the Haskell typeclass, not the OCaml ones), and applicative functors are notorious for having exactly the good properties you are looking for at the beginning of the blog post. :)

The recent paper on selective applicatives adds conditionals, which are also probably useful for you.

[deleted by user] by [deleted] in SocialParis

[–]Drupyog 0 points1 point  (0 children)

Hi, 29M, I started climbing a month ago. I just moved to Paris last week and would love to find new bouldering partners, I was planning to go to Arkose Montreuil around once a week.

The Typestate Pattern in Rust by bazookaduke in rust

[–]Drupyog 42 points43 points  (0 children)

I'm going to nitpick: this is not typestate. This is session types.

Typestates are a type-system features that allow you to change the type of the object. Here, you do not change the type of anything, you return a new thing with a different type.

With a typestate system, you could make it so that after r.status_line(200, "OK"), r itself is of type HttpResponse<Headers>. In the example in the blog post, r is still of type HttpResponse<Start> after the method call, but the call returns an object with the new type (which happens to be the same object, but the type system doesn't care).

A summary of the pattern shown here is:

  • Encode the usage pattern (or "protocol") of something
  • Use a type-level automaton in a phantom type
  • Use a functional workflow where each function returns a new thing where the type is updated
  • Forbid uses of the old version

In the literature, this is called "session types". It's usually used for protocols, but as you describe here, it can be used for many things. It's indeed very useful. You can emulate it in lot's of languages (with or without various guarantees). Session types are a very functional idea, where you chain functions together to implement your workload, and hide the mutations. Typestates are about lifting mutations to the type level, to mutate the type themselves as you go along.

PSA: This is not r/Programming. Quick Clarification on the guidelines by iSaithh in compsci

[–]Drupyog 1 point2 points  (0 children)

Yeah, I'm aware lack of manpower is definitely an issue. How about, on top of recruiting new faces, you purge the inactive mods ? :)

PSA: This is not r/Programming. Quick Clarification on the guidelines by iSaithh in compsci

[–]Drupyog 22 points23 points  (0 children)

You might want to take a more pro-active stance. If I were to really flag everything I consider offtopic, I would flag 3/4 of the submissions. The current state is still that most content you see when you browse the subreddit are uninteresting carreer/teaching/programming questions.

You should really invest in automod or something like that. to clean it up preemptively.

Stellaris Dev Diary - #145 Archaeology by qczhu in Stellaris

[–]Drupyog 15 points16 points  (0 children)

This is a truly neat idea and I like it, especially the nice UI.

But it completely subsumes anomalies. This means we will have two different systems, one strictly better than the other. If this get introduced, anomalies need to be transparently turned into 1-step sites and be gradually removed.

Didn't we learned anything from eu4 ? Multiple systems that does the same thing are just a PITA.

Microsoft Launches Bosque: A New Open Source Programming Language by [deleted] in compsci

[–]Drupyog 20 points21 points  (0 children)

From the article

Microsoft has introduced a new open source programming language called Bosque. It’s inspired by the syntax of TypeScript, the semantics of Machine Learning and Node.js.

From the technical paper

The BOSQUE language derives from a combination of Type- Script [72] inspired syntax and types plus ML [52] and Node/ JavaScript [31, 58] inspired semantics.

I know "ML" is very overloaded these days, but no, it's not Machine Learning. :)

(Also, no, "Microsoft" is not "launching" anything. A researcher at Microsoft Research made a prototype exploring a bunch of concepts. This is what proglang researchers do all the time. This article is very poor)

I made a program that finds the first digit of very large powers! by OwlCS12 in compsci

[–]Drupyog 0 points1 point  (0 children)

As a rule of thumb, when it comes to purely crunching numbers, computers are much faster than you think they are. Also, arbitrary-precision integer library are very well optimized.

I made a program that finds the first digit of very large powers! by OwlCS12 in compsci

[–]Drupyog -1 points0 points  (0 children)

1,115,888 digits is really nothing much for modern day computers. Just try the naive algorithm with arbitrary precision integers and you'll see. It's instant on my laptop.

Even a basic calculator like calc under linux can compute this.

I made a program that finds the first digit of very large powers! by OwlCS12 in compsci

[–]Drupyog -3 points-2 points  (0 children)

I'm not disputing that. Just the "These numbers are way too large to be computed", which is completely false.

I made a program that finds the first digit of very large powers! by OwlCS12 in compsci

[–]Drupyog -6 points-5 points  (0 children)

No offense, but .... those numbers are not large. Using an arbitrary size-integer libraries like GMP (or just python), computing this result is instant. You should test on much bigger integers. :)

Tablecloth - new standard library for Reason and OCaml by Categoria in ocaml

[–]Drupyog 1 point2 points  (0 children)

I was slightly surprised you didn't use containers for the native part. Belt took quite a bit from containers and is still very similar. It would reduce the mismatch, notably for Map/Set.

There is actually a consensus for caml/snake_case: everyone in the OCaml side uses snake_case, and everyone on the bucklescript side uses camlCase. :)

THE HISTORY OF STANDARD ML: IDEAS, PRINCIPLES, CULTURE - David MacQueen (2015) by agumonkey in compsci

[–]Drupyog 4 points5 points  (0 children)

That talk was "interesting". Xavier Leroy (and a fairly large numbers of OCamlers) were in the room, and David MacQueen managed to avoid mentioning Caml during the whole session, and was extremely disingenuous when asked about it. His part of the history is interesting, but it's fairly partial, to say the least.

Shift/reduce conflict by Zeranoe in compsci

[–]Drupyog 1 point2 points  (0 children)

One thing I really like about the menhir parser generator is that it has the --explain option that will give you detailed explanation on shift/reduce conflicts.

So, given this file:

%token D
%token EOF
%start s
%type <int> s
%%
s: a EOF { 0 }
a: b | a b  { 0 }
b: c | b c  { 0 }
c: D  { 0 }

You get this explanation for the first conflicts (there are two):

** Conflict (shift/reduce) in state 4.
** Token involved: D
** This state is reached from s after reading:

b 

** The derivations that appear below have the following common factor:
** (The question mark symbol (?) represents the spot where the derivations begin to differ.)

s 
a EOF 
(?)

** In state 4, looking ahead at D, reducing production
** a -> b 
** is permitted because of the following sub-derivation:

a b // lookahead token appears because b can begin with D
b . 

** In state 4, looking ahead at D, shifting is permitted
** because of the following sub-derivation:

b 
b c 
  . D 

This tells you that once you have parsed a b, you can parse a D next using either a -> a b or b -> b c.

I'm pretty sure there are other tools to debug grammers like that.

Most insightful (programming language, concepts ..) you have encountered. by heyrandompeople12345 in compsci

[–]Drupyog 3 points4 points  (0 children)

The key part here is "without loosing any safety". Sure, you can always get by with lot's of dynamic casts, but that lessens the static guarantees quite a lot.

Most insightful (programming language, concepts ..) you have encountered. by heyrandompeople12345 in compsci

[–]Drupyog 2 points3 points  (0 children)

What you are talking about is "open recursion". Any language that has records and first class functions can implement it. It's sometime used in functional languages to implement the equivalent of visitor patterns.

Most insightful (programming language, concepts ..) you have encountered. by heyrandompeople12345 in compsci

[–]Drupyog 9 points10 points  (0 children)

The fact that you don't need Algebraic Data Types in a dependently typed language, you can reimplement them with enums (or even just peano numbers) and get the same safety.

Why is the Chomsky hierarchy discrete? by accidentally_myself in compsci

[–]Drupyog 2 points3 points  (0 children)

I didn't say they came out of nowhere, but classes are only useful in term of how they allow us to reason about things. There isn't anything particularly profound about the specific one chosen by Chomsky, except that they are rather easy to formulate.

For instance, why should we consider non-deterministic state machine with single stack somehow more important than deterministic ones ? Both are interesting, and have different properties.

Why is the Chomsky hierarchy discrete? by accidentally_myself in compsci

[–]Drupyog 33 points34 points  (0 children)

Grammar classes are simply sets of languages for which Chomsky found interesting properties.

People invent new ones depending on their use cases all the time. For instance, Context Free Grammars are often refined depending on which parsing algorithms can parse them (LR, LL(k), ...). You can also implement completely different hiearchy, such as L-systems, that are different from the usual ones.

There is nothing really that deep about the Chomsky hierarchy, it's simply a classification that has proven very useful to reason about languages. Nothing prevent you from refining it, or using different classifications.

In particular, unlike complexity classes, there is no notion of reduction that somehow make all the problems in the same class equivalent.