Better HN
topnewbestaskshowjobs
Log inSign up

nrioux

4 karma · joined Aug 17, 2014 (12y ago) · 6 submissions

Submissions

comment 3y ago · link · parent

You asked for an example of Haskell influencing languages other than Idris. Type classes are a pretty clear example. I don't see how it is particularly relevant to this that they were motivated by a deficiency in SML.

I'm not familiar with the origin of traits/mixins in the OOP world, but my understanding is that they generally contain implementations of methods; they are a "part of" a class. Type classes and Rust traits, however, are more like interfaces. I'm pretty confident you won't find any notion of trait that predates type classes and can define what a Functor or Monad is. My reading of the SO answer you link is that Rust traits started off similar to type classes and have grown closer and closer over time. I'm not sure what a clearer indication of Haskell's influence would look like!

comment 3y ago · link · parent

Phil Wadler, the first author of the paper you cite, was literally a principal designer of Haskell. SML does not have type classes; your quote points out a deficiency in SML that motivates type classes.

My understanding is that "trait" is an unfortunately overloaded term. Traits in Rust are much more closely related to Haskell's type classes than to traits in the OOP sense.

comment 3y ago · link · parent

Rust's traits come to mind as one example.

comment 10y ago · link · parent

> Does this basically mean the language is immune via the compiler to failures or attacks from abstraction gaps between what high-level language shows and what low-level target actually does?

You're on the right track here. There's a very intuitive definition for 'compiler correctness':

Take any program in the source language and the corresponding target language program that a compiler gives you. Now run both programs using the semantics for the languages that each program is written in. If doing this gives you two equivalent results for all valid source programs, then your compiler is correct.

Assuming you have a good definition of 'equivalent results', this definition works very nicely for whole program compilers like the original work on CompCert. But what if you want to compile a component on its own, and then link it with a program later? It's not even obvious what correctness should mean if you support separate compilation because you can't 'run' a component.

It turns out there are different kinds of guarantees you might want to make about a compiler that constitute what is referred to as 'compositional compiler correctness'. Full abstraction is one of the strongest such guarantees. The abstract for this paper says that full abstraction means 'two source components are observationally equivalent in the source language if and only if their translations are observationally equivalent in the target'.

The key concept in this definition is the idea of 'observational equivalence'. We can say that two components C1 and C2 are observationally equivalent if for all programs P, there is no way for P to tell C1 and C2 apart; it must behave the same when linked with either one. That is, all of the observations that P can make about the component it's linked with are the same for both C1 and C2.

[1] (mentioned by the LtU post) talks a bit more about full abstraction and shows some issues that can arise when compilers accidentally break full abstraction. On the other hand, there are cases where it's impossible to write a fully abstract compiler. For example, if you have reflection in your target language but not your source language, it's likely that target level programs will always be able to distinguish between components which were equivalent in the source language. [2] is a good overview of many of the issues for those interested in compositional compiler correctness.

[1] http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.540... [2] http://www.ccs.neu.edu/home/amal/papers/verifcomp.pdf

comment 11y ago · link · parent

Is targeting Go source code like this really the best option for a Go-like language? I've been curious about hooking into some stage of Go's compiler. Looks like there is an intermediate Go assembly language, which PeachPy (https://github.com/Maratyszcza/PeachPy) can target. Not sure how well documented it is, though. Anyone know of other projects that do this?