From: danb
Subject: Greenspunning ML (revisited)
Date: 
Message-ID: <6a92cdb7-552b-4cdf-ad22-ded21580fb57@d45g2000hsc.googlegroups.com>
Well, I didn't like any of the pattern-matching libraries out there,
so I wrote another one.  The api is similar to Fare Rideau's fare-
matcher, with a couple extra features, but the internals are much more
straightforward, at the expense of not supporting unification at all.

Incidentally, the title of this post is derived from a message I
posted here a few months ago, forwarding a message from Fare about
fare-matcher.  c.l.l had recently been engaged in a troll war with Dr.
Frog, who had claimed that pattern matching in Lisp amounted to
Greenspunning ML.  The title was meant to be a parody of Dr. Frog, but
maybe some people took it otherwise (if they noticed it).  Anyway,
since I so rudely inflicted such an inconsiderate title on a post
about Fare's software, the least I could do was to take a well-
deserved dose of my own medicine.

So this library is called cl-match, and it uses the same s-expression
interface to ML-style matching as does fare-matcher, but it has a
couple extra features.  It allows multiple occurances of variable
names, with implied EQL comparisons, and allows branch-specific guards
to be embedded in individual branches where alternative patterns are
allowed (OR patterns).  The expanded code is optimized somewhat by
testing all single-branch patterns first.  There's some documentation
here:

http://www.prairienet.org/~dsb/clmatch.htm

The main page has links to a user's manual, a page on the internals,
and a download directory.  Please feel free to comment, criticize,
point out bugs, etc..

--Dan

------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/

From: Jon Harrop
Subject: Re: Greenspunning ML (revisited)
Date: 
Message-ID: <g8WdnS7Qy6nhiovVnZ2dnUVZ8vOdnZ2d@plusnet>
danb wrote:
> So this library is called cl-match, and it uses the same s-expression
> interface to ML-style matching as does fare-matcher, but it has a
> couple extra features.  It allows multiple occurances of variable
> names, with implied EQL comparisons, and allows branch-specific guards
> to be embedded in individual branches where alternative patterns are
> allowed (OR patterns).  The expanded code is optimized somewhat by
> testing all single-branch patterns first.

Can you implement proper decision-tree-based optimizations by augmenting
Lisp with some kind of closed algebraic data types equivalent to ML's
variant types?

That is where the enormous performance advantages lie...

> There's some documentation here:
> 
> http://www.prairienet.org/~dsb/clmatch.htm
> 
> The main page has links to a user's manual, a page on the internals,
> and a download directory.  Please feel free to comment, criticize,
> point out bugs, etc..

ML's pattern matching was designed to make it easy to convey
statically-checked constraints. I assume your Lisp implementation makes no
attempt to provide any static assurances at all. In which case, you may
find it more productive to Greenspun Mathematica's pattern matching
instead.

Also, you might like to reimplement this old benchmark using your new
library:

  http://www.lambdassociates.org/studies/study10.htm

HTH.

-- 
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
From: Marco Antoniotti
Subject: Re: Greenspunning ML (revisited)
Date: 
Message-ID: <5311bc63-3b76-4830-bf72-3ec11439cbff@c58g2000hsc.googlegroups.com>
On Apr 28, 8:23 pm, Jon Harrop <····@ffconsultancy.com> wrote:
> danb wrote:
> > So this library is called cl-match, and it uses the same s-expression
> > interface to ML-style matching as does fare-matcher, but it has a
> > couple extra features.  It allows multiple occurances of variable
> > names, with implied EQL comparisons, and allows branch-specific guards
> > to be embedded in individual branches where alternative patterns are
> > allowed (OR patterns).  The expanded code is optimized somewhat by
> > testing all single-branch patterns first.
>
> Can you implement proper decision-tree-based optimizations by augmenting
> Lisp with some kind of closed algebraic data types equivalent to ML's
> variant types?

Yes.  It can be done.

> That is where the enormous performance advantages lie...
>
> > There's some documentation here:
>
> >http://www.prairienet.org/~dsb/clmatch.htm
>
> > The main page has links to a user's manual, a page on the internals,
> > and a download directory.  Please feel free to comment, criticize,
> > point out bugs, etc..
>
> ML's pattern matching was designed to make it easy to convey
> statically-checked constraints. I assume your Lisp implementation makes no
> attempt to provide any static assurances at all. In which case, you may
> find it more productive to Greenspun Mathematica's pattern matching
> instead.

Of course the OP library does not implement the full blown unification
based ML type checking algorithm.  It is because pattern (unification)
matching is a component (arguably the most important) of static type
checking.  In other words, they are different things.

Cheers
--
Marco
From: Slobodan Blazeski
Subject: Re: Greenspunning ML (revisited)
Date: 
Message-ID: <1094b0b2-dbdb-480f-b4f9-3697a901995d@m36g2000hse.googlegroups.com>
On Apr 28, 3:28 pm, danb <·········@gmail.com> wrote:
> c.l.l had recently been engaged in a troll war with Dr.
> Frog,
What war are you talking about ?  Single toad waving with plastic
sword, and took so much beating
that even heartless start to feel sorry about poor pond dweller.
Than somebody called Animal Protection Agency and show was over.

Slobodan
From: John Thingstad
Subject: Re: Greenspunning ML (revisited)
Date: 
Message-ID: <op.uafbc7qsut4oq5@pandora.alfanett.no>
P� Wed, 30 Apr 2008 14:03:51 +0200, skrev Slobodan Blazeski  
<·················@gmail.com>:

> On Apr 28, 3:28�pm, danb <·········@gmail.com> wrote:
>> �c.l.l had recently been engaged in a troll war with Dr.
>> Frog,
> What war are you talking about ?  Single toad waving with plastic
> sword, and took so much beating
> that even heartless start to feel sorry about poor pond dweller.
> Than somebody called Animal Protection Agency and show was over.
>
> Slobodan

You might need a fortress to protect yourself.
(Check Guy Steele's current activeties at Sun.)

--------------
John Thingstad
From: Slobodan Blazeski
Subject: Re: Greenspunning ML (revisited)
Date: 
Message-ID: <1f1287ae-cf61-49a1-9963-5926529bf7f7@a1g2000hsb.googlegroups.com>
On Apr 30, 2:23 pm, "John Thingstad" <·······@online.no> wrote:
> På Wed, 30 Apr 2008 14:03:51 +0200, skrev Slobodan Blazeski  
> <·················@gmail.com>:
>
> > On Apr 28, 3:28 pm, danb <·········@gmail.com> wrote:
> >>  c.l.l had recently been engaged in a troll war with Dr.
> >> Frog,
> > What war are you talking about ?  Single toad waving with plastic
> > sword, and took so much beating
> > that even heartless start to feel sorry about poor pond dweller.
> > Than somebody called Animal Protection Agency and show was over.
>
> > Slobodan
>
> You might need a fortress to protect yourself.
> (Check Guy Steele's current activeties at Sun.)

What activities? http://projectfortress.sun.com/Projects/Community/wiki/FortressStartHere
A project inspired by Scala, Standard ML, and Haskell that runs on
JVM, no thank you.
cl/scheme, j/q, joy, prolog and erlang made a high threshold on what's
acceptable for me.

>
> --------------
> John Thingstad
From: Jon Harrop
Subject: Re: Greenspunning ML (revisited)
Date: 
Message-ID: <taKdncJGa4NP6IXVnZ2dnUVZ8sHinZ2d@plusnet>
Slobodan Blazeski wrote:
> On Apr 30, 2:23�pm, "John Thingstad" <·······@online.no> wrote:
>> You might need a fortress to protect yourself.
>> (Check Guy Steele's current activeties at Sun.)
> 
> What activities?
> http://projectfortress.sun.com/Projects/Community/wiki/FortressStartHere A
> project inspired by Scala, Standard ML, and Haskell that runs on JVM, no
> thank you.

Inspired by Scala and Java maybe but not SML and Haskell (or OCaml, or F#).
Fortress is extremely verbose and fails to capture the productivity of ML
and Haskell. Scala is the same.

Fortress can't even represent "hello world" without many unnecessary
declarations including type declarations:

  component HelloWorld                                                                                                                    
  export Executable                                                                                                                       
    run(args:String...):() = do                                                                                                           
        println("Hello, world!" )                                                                                                         
    end                                                                                                                                   
  end

Contrast with F#:

  printf "Hello, world!"

-- 
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
From: Jochen Schmidt
Subject: Re: Greenspunning ML (revisited)
Date: 
Message-ID: <fa1c4840-cee8-48ad-b3b4-b14803df458b@e39g2000hsf.googlegroups.com>
On 30 Apr., 15:30, Dr Jon D Hoparound wrote:

> Fortress can't even represent "hello world" without many unnecessary
> declarations including type declarations:

Oh I see - that wouldn't fit the needs of your typical customer
then...
I could implement a domain specific language for you (and them) which
is optimized to generate type proven "hello world"s without needing
unnecessary declarations:

Here is the program:
"hello world"

interested?

Jochen Schmidt
From: ···················@gmail.com
Subject: Re: Greenspunning ML (revisited)
Date: 
Message-ID: <eed23a7f-f42a-44f0-bd16-04b9a1995688@m45g2000hsb.googlegroups.com>
On 33 Apr, 11:11, <jon.flying.at.com> wroted:

>   printF "Hello worldF"

...sorry, forgot to mention:

The most important letter here is the 'F' (standing for, you know).

-JH
From: Reini Urban
Subject: Re: Greenspunning ML (revisited)
Date: 
Message-ID: <481DC5C0.5060802@x-ray.at>
Jon Harrop schrieb:
> Slobodan Blazeski wrote:
>> On Apr 30, 2:23 pm, "John Thingstad" <·······@online.no> wrote:
>>> You might need a fortress to protect yourself.
>>> (Check Guy Steele's current activeties at Sun.)
>> What activities?
>> http://projectfortress.sun.com/Projects/Community/wiki/FortressStartHere A
>> project inspired by Scala, Standard ML, and Haskell that runs on JVM, no
>> thank you.
> 
> Inspired by Scala and Java maybe but not SML and Haskell (or OCaml, or F#).
> Fortress is extremely verbose and fails to capture the productivity of ML
> and Haskell. Scala is the same.
> 
> Fortress can't even represent "hello world" without many unnecessary
> declarations including type declarations:
> 
>   component HelloWorld                                                                                                                    
>   export Executable                                                                                                                       
>     run(args:String...):() = do                                                                                                           
>         println("Hello, world!" )                                                                                                         
>     end                                                                                                                                   
>   end
> 
> Contrast with F#:
> 
>   printf "Hello, world!"

Not true.
You are complaining that the component above is more verbose than the 
typical single liner.
The language specs http://research.sun.com/projects/plrg/fortress.pdf 
lists this one-liner executable as:
   export Executable
   run(args) = print “Hello, world!”

and runs it with
  $ fortress run HelloWorld.fss

The component holds an object, which is more than a single exe.

This is nice:
"Fortress allows recursive, and mutually recursive function definitions."
   factorial (n) =
     if n = 0 then 1
     else n factorial (n − 1) end

Note that "n factorial (n − 1)" means "n * factorial(n − 1)".
The magic, invisible multiplication operator.