Live data from Hacker News

Beautiful Racket

beautifulracket.com

41–50 of 55 posts

Re: Beautiful Racket

#41
post #31
post #4

This looks like a very well-written, easy introduction to making simple, dynamic programming languages (not surprising given the author's writing background). But everyone writes about how to build these kinds of basic Forths, or Lisps, or reverse polish notation calculators. To be honest, once you've learned the basic technique, writing a toy dynamic language interpreter is pretty easy. Even adding a toy JIT isn't v…

Do you find "Types and Programming Languages" to be a slog?

I've not yet wanted to shell out for Types and Programming Languages in the hopes of finding something online, but given that it covers exactly what I need at this moment, I'll probably go ahead and buy it. And no, excerpts from Pierce I've looked at in the past looked perfect for my level.

That said, the old Peyton Jones textbook that was referenced above looks pretty interesting. Might work through that one before I buy Types and Programming Languages.

Re: Beautiful Racket

#42
post #10
post #6

Earlier quoted context omitted.

Are you looking for general references on implementing type checkers and ML-like languages? Or how to implement those as languages in Racket specifically?

Either or any would be great, particularly if they're online and not books (although I'd buy a good book that covered those topics in depth). Particularly an approachable intro to Hindley-Milner and building a toy/mini-ML, and type checking in general. All the better if it's in Racket, or some ML. Actually, do you know of any examples of ML-type languages, or any statically-typed languages, that are written in Racket…

There is a simple ML-like language implemented in Racket, called plai-typed, which is used by some people for teaching the PLAI programming language book. You can see the implementation here: https://github.com/mflatt/plai-typed

Re: Beautiful Racket

#43
post #30

Earlier quoted context omitted.

This is the only time I've heard "datum" used outside the context of GIS.

Datum is the singular of data.

In Latin. In English "data" is a mass noun. Nobody really says "data are" unless they're writing an academic paper.

Re: Beautiful Racket

#44
post #38
post #35

Earlier quoted context omitted.

The singular of data would be a 1 , to be pedantic. Edit: Information is uncountable, so maybe data should as well be. Is that plural or singular? Yes, you can have sand and a grain of sand, but the grain is hardly sandy. A lone 1 is hardly, excuse the pun, dative.

'data' comes from latin, and 'data' is plura. the singular is 'datum'. In Italian (the direct descendent of latin) there is both singular and plural for datum (singular: 'dato', plural: 'dati')

that's totally ignoring what I said. I hope you feel smug about it.

Edit: Interestingly, wiktionary says informations is just uncommon, and that information is not data, it's the meaning of data, in the computing context. ... with source. It links to a paper about an ISO standard, no less, that tries to define vocabulary and happens to use data as singular. Document Reader [is a] Character reader whose input data is the text from specific areas on a given type of form [1]. (This makes me so happy right now.)

Overall, if it's a technical term they invented, the authors are free to name their language construct whatever they want. But if it's so fudged that the author even writes datums ... I rest my case.

[1] https://www.iso.org/obp/ui/#iso:std:iso-iec:2382:ed-1:v1:en

Re: Beautiful Racket

#45
post #4

This looks like a very well-written, easy introduction to making simple, dynamic programming languages (not surprising given the author's writing background). But everyone writes about how to build these kinds of basic Forths, or Lisps, or reverse polish notation calculators. To be honest, once you've learned the basic technique, writing a toy dynamic language interpreter is pretty easy. Even adding a toy JIT isn't v…

Perhaps MinCaml: http://esumii.github.io/min-caml/index-e.html

Re: Beautiful Racket

#46
post #4

This looks like a very well-written, easy introduction to making simple, dynamic programming languages (not surprising given the author's writing background). But everyone writes about how to build these kinds of basic Forths, or Lisps, or reverse polish notation calculators. To be honest, once you've learned the basic technique, writing a toy dynamic language interpreter is pretty easy. Even adding a toy JIT isn't v…

I have a compile-to-Racket implementation of a Pascal subset here:

https://github.com/soegaard/minipascal

There are two versions. The first one

    https://github.com/soegaard/minipascal/blob/master/minipascal/compiler-simple.rkt
is without typechecking. The second one adds a type checker:

https://github.com/soegaard/minipascal/blob/master/minipasca...

Re: Beautiful Racket

#47
post #37
post #4

This looks like a very well-written, easy introduction to making simple, dynamic programming languages (not surprising given the author's writing background). But everyone writes about how to build these kinds of basic Forths, or Lisps, or reverse polish notation calculators. To be honest, once you've learned the basic technique, writing a toy dynamic language interpreter is pretty easy. Even adding a toy JIT isn't v…

> What I want more than anything is a guide written on the same level on how to build a toy statically-typed language, with algebraic data types. The answers here might be useful: http://stackoverflow.com/questions/12532552/what-part-of-mil... > Is there no very simple introduction on writing a simple ML, with type checking? Any recommended resources? I'd recommend reading A. Field, P. Harrison, "Functional Programmi…

"find an embeddable Prolog compiler for your language of choice (e.g., MiniKanren for Racket), and then simply emit a flat list of Prolog equations out of your source language AST (do the lexical scoping pass first). Easy. And easily extendable to dependent typing and all that fancy stuff."

So, you represent the AST associations and type-checks as Prolog logic rules that operate on predicates describing the AST? And the inference engine runs through it to dump out true or false for various predicates and rules? Am I understanding it right?

Also, didn't realize Prolog could handle dependent types and such. That's neat to know.

Re: Beautiful Racket

#48
post #37

Earlier quoted context omitted.

> What I want more than anything is a guide written on the same level on how to build a toy statically-typed language, with algebraic data types. The answers here might be useful: http://stackoverflow.com/questions/12532552/what-part-of-mil... > Is there no very simple introduction on writing a simple ML, with type checking? Any recommended resources? I'd recommend reading A. Field, P. Harrison, "Functional Programmi…

"find an embeddable Prolog compiler for your language of choice (e.g., MiniKanren for Racket), and then simply emit a flat list of Prolog equations out of your source language AST (do the lexical scoping pass first). Easy. And easily extendable to dependent typing and all that fancy stuff." So, you represent the AST associations and type-checks as Prolog logic rules that operate on predicates describing the AST? And…

For example, you have an AST node for 'x + 2', encoded as 'apply(apply(var("+"), var("x")), const("2"))' (we're talking about ML, so it is curried here).

Firstly, all the expression nodes must be annotated with type tags: 'A1:apply(A2:apply(A3:var("plus"),A4:var("x")), A5:const("2"))'.

Then your typing pass walking over this segment of AST would generate the following (mostly trivial) equations

    A5=integer  // from constant type
    A4=Vx

    A3=Vplus
    A3=fun(integer, fun(integer, integer)) // from environment lookup
    A3=fun(V1, A2) // application rule
    A2=fun(V2, A1) // application rule

Then this long Prolog query (all equations are comma separated) is executed and you'll get all An type values to attach to your AST, as well as variable x type.

> Prolog could handle dependent types

It's Turing-complete. You can encode anything you want in it.

Re: Beautiful Racket

#49
post #48

Earlier quoted context omitted.

"find an embeddable Prolog compiler for your language of choice (e.g., MiniKanren for Racket), and then simply emit a flat list of Prolog equations out of your source language AST (do the lexical scoping pass first). Easy. And easily extendable to dependent typing and all that fancy stuff." So, you represent the AST associations and type-checks as Prolog logic rules that operate on predicates describing the AST? And…

For example, you have an AST node for 'x + 2', encoded as 'apply(apply(var("+"), var("x")), const("2"))' (we're talking about ML, so it is curried here). Firstly, all the expression nodes must be annotated with type tags: 'A1:apply(A2:apply(A3:var("plus"),A4:var("x")), A5:const("2"))'. Then your typing pass walking over this segment of AST would generate the following (mostly trivial) equations A5=integer // from con…

"Then your typing pass walking over this segment of AST would generate the following (mostly trivial) equations"

Thanks for the example. That does seem straight-forward.

"It's Turing-complete. You can encode anything you want in it."

The reason I mention it is that many people doing proofs and such specifically avoid first-order logic in favor of HOL or Coq. They sometimes mention FOL is too limited or you have to go out of your way for what they're doing. Not specialist enough to have figured out what they're talking about. There appears, though, to be some cutoff point where one is better off using HOL-style tools for analysis, proof, synthesis, whatever. Wish I had references on-hand if it's not clear already what I'm talking about.

Re: Beautiful Racket

#50
post #39
post #10

Earlier quoted context omitted.

Either or any would be great, particularly if they're online and not books (although I'd buy a good book that covered those topics in depth). Particularly an approachable intro to Hindley-Milner and building a toy/mini-ML, and type checking in general. All the better if it's in Racket, or some ML. Actually, do you know of any examples of ML-type languages, or any statically-typed languages, that are written in Racket…

Not in Racket, but still a Lisp: https://github.com/combinatorylogic/mbase/tree/master/src/l/...

That is quite a broad and instructive project, very interested to see the Prolog type checking you describe below in action. Thanks!
Post reply on HN