News for hackers. Stuff that matters.
Re:Mirth – a type-safe concatenative purely functional progr... by hombre_fatal on Friday July 12, 2019 @02:23PM (#20423058)
I was interested by the title, but it really needs a quick-start + examples in the readme.
Re:Mirth – a type-safe concatenative purely functional progr... by ssalka on Friday July 12, 2019 @03:06PM (#20423449)
Came here to say this. Majority of engineers will bounce immediately once they see there is no code snippets in the README, nor an examples folder.
Re:Mirth – a type-safe concatenative purely functional progr... by tomsmeding on Friday July 12, 2019 @03:50PM (#20423849)
To be frank, the src/ folder is the compiler for Mirth written in Mirth, so there's your example code. However, I do agree that a quick introduction would not be out of place.
Re:Mirth – a type-safe concatenative purely functional progr... by paulddraper on Friday July 12, 2019 @04:42PM (#20424321)
But the first thing I want to about C is not a compiler written in C. That's an unfriendly intro to almost any language.

I want to see a procedure call, "Hello world" I/O, some math or string manipulation, and how to run that myself.

After that I can look at compiler sources.

Re:Mirth – a type-safe concatenative purely functional progr... by edejong on Friday July 12, 2019 @05:57PM (#20424888)
LISP is a notable exception. Btw, I do believe a compiler should be one of the examples of a new language.
Re:Mirth – a type-safe concatenative purely functional progr... by bogdanoff_2 on Friday July 12, 2019 @10:58PM (#20426237)
Are you saying that lisps are an exception to needing to see some small examples at first when looking at a new language? Why do you think they're an exception?
Re:Mirth – a type-safe concatenative purely functional progr... by edejong on Saturday July 13, 2019 @06:55AM (#20427463)
In LISP-like languages a compiler/interpeter is a simple example.
Re:Mirth – a type-safe concatenative purely functional progr... by kazinator on Sunday July 14, 2019 @12:28AM (#20431637)
https://github.com/sbcl/sbcl/tree/master/src/compiler

Doesn't look simple to me.

This one is in one file, but more than half a megabyte of code spanning close to 12000 lines:

https://github.com/clisp-lang/clisp/blob/master/src/compiler...

The Emacs Lisp byte compiler also doesn't look like a good small example for neophytes:

http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-l...

Re:Mirth – a type-safe concatenative purely functional progr... by garmaine on Friday July 12, 2019 @06:59PM (#20425287)
FWIW, concatinative languages are even simpler than Lisp.
Re:Mirth – a type-safe concatenative purely functional progr... by garmaine on Friday July 12, 2019 @04:23PM (#20424150)
True, and that would be a good thing for the README to emphasize. It's mentioned, but in passing.

But even so, I know I'd like a good reference of what primitive operations are, the type system, and what's provided by the Prelude.

Re:Mirth – a type-safe concatenative purely functional progr... by 0815test on Saturday July 13, 2019 @01:44AM (#20426680)
I've looked at some basic library code that is implemented as part of the compiler, and... well, I'm not sure about this. The syntax does not really seem reminiscent of concatenative languages ala FORTH, so in what sense is this a "concatenative" language? The documentation doesn't say - there is no documentation to speak of. I'm not going to dismiss the effort that has been put into this already, but I'd sure like to see some more overall polish applied - then it could even be reposted to HN, and perhaps garner far more useful critiques.
Re:Mirth – a type-safe concatenative purely functional progr... by garmaine on Saturday July 13, 2019 @10:43AM (#20428270)
Are we looking at the same thing? It’s definitely a post-fix stack based language. It just also has strong ML-like types.
Re:Mirth – a type-safe concatenative purely functional progr... by wjsetzer on Friday July 12, 2019 @03:43PM (#20423775)
I think even beyond that, I didn't see a link to any docs in the readme. It may be cool, but I can't use it if there's nothing to tell me how.
Re:Mirth – a type-safe concatenative purely functional progr... by detaro on Friday July 12, 2019 @02:24PM (#20423067)
I found some more information in posts on the patreon page, but not a good intro.
Re:Mirth – a type-safe concatenative purely functional progr... by agentofuser on Friday July 12, 2019 @05:09PM (#20424538)
Re:Mirth – a type-safe concatenative purely functional progr... by nudpiedo on Friday July 12, 2019 @07:54PM (#20425577)
I have no idea how to read or make sense of these definitions. I mean semantically and grammatically. What should I read if I want to understand those snippets and how/why they do define what an addition is?
Re:Mirth – a type-safe concatenative purely functional progr... by dan-robertson on Saturday July 13, 2019 @09:48AM (#20428038)
The first confusing thing is the type signatures. Concatenative languages pass everything around with a stack so here the double dash separates a top part of the stack before application from what the application of the word transforms that bit of the stack into, so:

  succ : Nat -- Nat
means that if you can prove there is a Nat, n on the top of the stack, you can do succ to replace that with a Nat, succ n. Similarly we have:

  + : Nat Nat -- Nat
Which says if you have two Nats on the top of the stack you can do + to get a single Nat.

The next weird thing is pattern matching. + is defined with two cases. The first is:

  zero + = id
Which makes some sense: to add zero to x, do nothing. Making up a variable syntax it would look like:

  <x> zero + = <x>
The pattern matching on the next line is harder:

  succ + = + succ
Which (making up syntax again) says that if your stack looks like:

  m n
And n = succ k:

  m (succ k)
And you do +, you “unapply” succ to get a “stack” that looks like:

  m k succ
With the application of + shown:

  m k succ +
And this matches the pattern above so we transform:

  m k + succ
And evaluate:

  (m+k) succ
  (m+k+1)
  (m+n)
I think this is a rough idea of how the basic types work:

  Denote a “stack” of types (e.g. Nat Nat above) as [a], and single types a.
  If e : [a] -- [b] then for any [c], e : [c] [a] -- [c] [b]
  If dashes are omitted from a type a, it is the same as the type -- a (ie [b] -- [b] a for any [b])
  If e : [a] -- [b] and f : [b] -- [c] then e f : [a] -- [c]

  To define a word w : [a] -- [b], e w = f is a valid clause if:
  1. e has type [c] -- [a]
  2. f has type [c] -- [b]
  3. e is a valid pattern (ie made out of constructors (?))
I guess the rest of the typing rules are more complicated.
Re:Mirth – a type-safe concatenative purely functional progr... by Smaug123 on Saturday July 13, 2019 @02:48AM (#20426855)
The syntax is a bit peculiar, but they defined the union type Nat, defined the function + which takes two Nats and returns a Nat (which they defined in a thoroughly confusing point-free way because the language is concatenative), and demonstrated the associativity of +.

If you read any introduction to dependent types, they will do this.

Re:Mirth – a type-safe concatenative purely functional progr... by nudpiedo on Saturday July 13, 2019 @05:23AM (#20427249)
Ok, now I get it... I was just lost in the syntax.
Re:Mirth – a type-safe concatenative purely functional progr... by hashmal on Friday July 12, 2019 @04:44PM (#20424328)
It's unbelievable how many languages are introduced without an example on the homepage. Imagine an Apple homepage without any iPhone pictures.
Re:Mirth – a type-safe concatenative purely functional progr... by agentofuser on Friday July 12, 2019 @05:02PM (#20424463)
It's unbelievable how entitled people can be towards things that are published for free by authors who owe them nothing.

Mirth hasn't been released. I found it and decided to share it.

Re:Mirth – a type-safe concatenative purely functional progr... by dmitriid on Friday July 12, 2019 @05:09PM (#20424542)
> Mirth hasn't been released. I found it and decided to share it.

So you are actually doing it a disservice. Perhaps the author intended a larger release with better docs and examples (or no release at all if it’s a toy project).

But now it will be yet another “ah, one of those languages with no documentation or viable use cases”.

Languages are a dime a dozen, there are several of then on HN each weak. “How dare you demand something from something made for free” is not a credible defence for anything.

Re:Mirth – a type-safe concatenative purely functional progr... by tluyben2 on Friday July 12, 2019 @10:43PM (#20426202)
A Forth-y with types, let alone dependent types, are not ‘a dime a dozen’.