Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Closest statically typed FP "cousin" to Scheme?

118 views
Skip to first unread message

Grant Rettke

unread,
Oct 6, 2008, 3:28:23 PM10/6/08
to
What is the best statically typed FP for person to learn coming from
Scheme as his first FP?

Aaron W. Hsu

unread,
Oct 6, 2008, 10:21:40 PM10/6/08
to
Grant Rettke <gre...@gmail.com> writes:

>What is the best statically typed FP for person to learn coming from
>Scheme as his first FP?

Scheme maybe? :-) I think there is such a thing as Typed Scheme.

Aaron Hsu

--
+++++++++++++++ ((lambda (x) (x x)) (lambda (x) (x x))) +++++++++++++++
Email: <arc...@sacrideo.us> | WWW: <http://www.sacrideo.us>
Scheme Programming is subtle; subtlety can be hard.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Michele Simionato

unread,
Oct 7, 2008, 1:12:16 AM10/7/08
to
On Oct 6, 9:28 pm, Grant Rettke <gret...@gmail.com> wrote:
> What is the best statically typed FP for person to learn coming from
> Scheme as his first FP?

Coming from Scheme I liked very much SML. Notice however that a
statically type functional language is very different from a
dynamically typed one, so it will take some time to adjust.

Michele Simionato

Benjamin L. Russell

unread,
Oct 7, 2008, 1:51:09 AM10/7/08
to
On Mon, 06 Oct 2008 21:21:40 -0500, Aaron W. Hsu <arc...@sacrideo.us>
wrote:

>Grant Rettke <gre...@gmail.com> writes:
>
>>What is the best statically typed FP for person to learn coming from
>>Scheme as his first FP?
>
>Scheme maybe? :-) I think there is such a thing as Typed Scheme.

You can find out more about Typed Scheme at the following Web site:

Typed Scheme: Scheme with Static Types
http://docs.plt-scheme.org/typed-scheme/

You may also wish to check out Liskell, a Scheme/Lisp-stype front-end
for Haskell:

About Liskell
http://liskell.org/

I was not able to figure out whether Liskell in a Lisp-1 (i.e., a Lisp
dialect with a single namespace, such as Scheme) or a Lisp-2 (i.e., a
Lisp dialect with separate namespaces for functions and variables,
such as Common Lisp). However, Liskell's syntax for function
definition closely resembles that of Scheme. More information can be
found in the following paper:

Liskell: Haskell Semantics with Lisp Syntax
http://clemens.endorphin.org/ILC07-Liskell-draft.pdf

Here is an excerpt from the above-mentioned paper (see Figure 4 on
page 8) comparing sample code in Haskell, Liskell, and Common Lisp for
a function add-move for a Tic Tac Toe game (apologies in advance for
any formatting problems--the code came out without spaces when I
pasted from the PDF document, and I had to insert spaces manually back
into the code):

Haskell version:

add_move (stateA , stateB)
move
player =
case player of
’a’ -> (insert move stateA ,
stateB)
’b’ -> (stateA ,
insert move stateB)

Liskell version:

(define (add - move (, stateA
stateB)
move
player)
(case player
(#\ a (, (insert move
stateA)
stateB))
(#\ b (, stateA
(insert move
stateB)))))

Common Lisp version:

(defun add - move (state move player)
(case player
(a (cons (cons move
(car state))
(cdr state)))
(b (cons (car state)
(cons move
(cdr state))))))

According to the document, in the above code, the Haskell and Liskell
semantics are identical, while the Common Lisp semantics differ in
that the CL code does not use a tuple, but an untyped cons cell:

>Figure 4 features a direct comparison of one of Tic Tac Toe’s
>functions: add-move. The semantic of the Haskell . on the
>left . and Liskell code . in the middle . are identical. Both
>use pattern matching to destructure a tuple in the function
>arguments, carry out a case analysis on the player argument
>given as character, and reassemble a tuple with either the
>first or the second tuple part modified by the insert function.
>
>The Common Lisp (cl) variant on the right works similarly,
>with the exception that it does not use a tuple but an untyped
>cons cells, and that it has to use accessors functions
>as cl lacks destructuring in function arguments.

Please let me know in this thread if you find out whether Liskell in a
Lisp-1 or a Lisp-2.

-- Benjamin L. Russell

Anton van Straaten

unread,
Oct 7, 2008, 7:37:10 AM10/7/08
to
Benjamin L. Russell wrote:
> You may also wish to check out Liskell, a Scheme/Lisp-stype front-end
> for Haskell:
>
> About Liskell
> http://liskell.org/
>
> I was not able to figure out whether Liskell in a Lisp-1 (i.e., a Lisp
> dialect with a single namespace, such as Scheme) or a Lisp-2 (i.e., a
> Lisp dialect with separate namespaces for functions and variables,
> such as Common Lisp).

I believe it's a Lisp-1 with respect to ordinary function and variable
names, following Haskell's approach to namespace issues.

I like the idea of Liskell, but one practical problem with it is that
it's apparently implemented as a branch of the GHC code base. The
version currently available at http://liskell.org/download is based on
GHC 6.6, which is already fairly out of date - the latest stable version
of GHC is 6.8.3.

Anton

Anton van Straaten

unread,
Oct 7, 2008, 8:15:07 AM10/7/08
to
Grant Rettke wrote:
> What is the best statically typed FP for person to learn coming from
> Scheme as his first FP?

What are your goals here?

If you want to be able to use Scheme alongside a typed language, then
Typed Scheme could be a good choice, depending on what you plan to do
with it. It would also almost certainly involve learning the least.

If you want to learn a more traditional typed functional language, and
keep additional learning to a minimum, then SML might make sense both
because it's relatively close to Scheme in its semantics, and because
it's "small" for a typed functional language. It'll teach you the
essentials of typed functional programming.

However, if you want to be able to write non-academic programs in a
typed functional language, you're probably better off with OCaml or
Haskell, both of which have larger communities involved in development
of not-purely-academic code, and thus tend to have more
practically-oriented libraries and other resources available, including
tutorials and online assistance from other users. Haskell seems to have
the edge here, currently.

Of those two, OCaml is closer to Scheme's semantics just by virtue of
(a) having eager rather than lazy evaluation and (b) supporting impure
programming with less fuss, so you don't need to understand monads to
perform basic practical tasks. The core of OCaml is semantically very
close to SML and can be learned just as easily.

On the other hand, if you're looking to stretch your brain, Haskell is
worth learning. Some might argue that you haven't really done
functional programming unless you've done pure functional programming.
The combination of purity, lazy evaluation, and a highly advanced type
system (particularly in the main Haskell implementation, GHC), makes for
a programming style significantly different from that of the
(relatively) impure, strict languages like SML, OCaml, and Scheme.

Anton

namekuseijin

unread,
Oct 7, 2008, 1:26:53 PM10/7/08
to
On Oct 6, 4:28 pm, Grant Rettke <gret...@gmail.com> wrote:
> What is the best statically typed FP for person to learn coming from
> Scheme as his first FP?

Have you looked at Stalin or Bigloo?

Slobodan Blazeski

unread,
Oct 9, 2008, 11:18:37 AM10/9/08
to
On Oct 6, 9:28 pm, Grant Rettke <gret...@gmail.com> wrote:
> What is the best statically typed FP for person to learn coming from
> Scheme as his first FP?

Qi www.lambdassociates.org most powerful type system plus static type
checks are optional plus you can use cl under the hood.

bobi

Grant Rettke

unread,
Oct 9, 2008, 11:24:00 AM10/9/08
to
On Oct 6, 9:21 pm, Aaron W. Hsu <arcf...@sacrideo.us> wrote:
> Scheme maybe? :-) I think there is such a thing as Typed Scheme.

Yes, PLT Typed Scheme.

Ok, the closest thing that is not Scheme :).

Grant Rettke

unread,
Oct 9, 2008, 11:24:24 AM10/9/08
to
On Oct 7, 12:12 am, Michele Simionato <michele.simion...@gmail.com>
wrote:

> Coming from Scheme I liked very much SML. Notice however that a
> statically type functional language is very different from a
> dynamically typed one, so it will take some time to adjust.

Understood. I expect it.

Grant Rettke

unread,
Oct 9, 2008, 11:29:01 AM10/9/08
to
On Oct 7, 7:15 am, Anton van Straaten <an...@appsolutions.com> wrote:
> Grant Rettke wrote:
> > What is the best statically typed FP for person to learn coming from
> > Scheme as his first FP?
>
> What are your goals here?

Maximum learning.

Also as I am getting one perspective on FP with Scheme, and I would
like to see another.

> [regarding SML] It'll teach you the


> essentials of typed functional programming.

Sounds like a good place to start.

> On the other hand, if you're looking to stretch your brain, Haskell is
> worth learning.  

:)

> Some might argue that you haven't really done
> functional programming unless you've done pure functional programming.

What do they say if you done pure FP in Scheme?

> The combination of purity, lazy evaluation, and a highly advanced type
> system (particularly in the main Haskell implementation, GHC), makes for
> a programming style significantly different from that of the
> (relatively) impure, strict languages like SML, OCaml, and Scheme.

Interesting!

Grant Rettke

unread,
Oct 9, 2008, 11:29:20 AM10/9/08
to

No I haven't.

Grant Rettke

unread,
Oct 9, 2008, 11:56:05 AM10/9/08
to
On Oct 7, 7:15 am, Anton van Straaten <an...@appsolutions.com> wrote:

> On the other hand, if you're looking to stretch your brain

Does learning SML do much brain-stretching?

Michele Simionato

unread,
Oct 9, 2008, 12:03:46 PM10/9/08
to

Less than Haskell, but yes, it requires some brain-stretching and it
is definitely
a language worth studying. Personally, as a side effect, after
studying SML
I understood Scheme much better. The brain works in strange ways, so
after SML
I misteriously started liking syntax-case which I had neglected for
years.

Jon Harrop

unread,
Oct 10, 2008, 3:25:34 AM10/10/08
to
Grant Rettke wrote:
> What is the best statically typed FP for person to learn coming from
> Scheme as his first FP?

Simplicity was a key design goal for Scheme so, on that basis, you may well
find Standard ML (SML) to be the nearest parallel to Scheme. The flip side
is that SML shares many of Scheme's problems with respect to practicality.
I would also argue that SML is more domain specific than Scheme because it
is not an extensible language and is lacking in some important ways.

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?u

Jon Harrop

unread,
Oct 10, 2008, 3:49:00 AM10/10/08
to

If you have no prior experience of static typing with type inference then
SML will certainly stretch your brain and will do so safely because you are
in the confines of a minimal, well-defined and elegant language.

I highly recommend SML as the first such language to learn (it was mine in
the same context). You probably want to focus on the following aspects of
SML:

1. Variant types as sum and product types and coding styles that maximize
the effectiveness of ML-style type checking.

2. Pattern matching with exhaustiveness and redundancy checking as a way to
destructure data safely and efficiently.

3. Functors for safe large-scale abstractions.

The next languages to learn from that corner of the language zoo are OCaml,
Haskell and possibly F#.

OCaml adds many useful features to SML (inferred sum types, pattern guards,
or-patterns, structural hashing, objects, Camlp4 macros) but lacks SML's
equality types and well-defined notion of equality.

Haskell brings purity, non-strict evaluation semantics and a more powerful
type system.

F# adds many useful features (OCaml's pattern matching extensions as well as
views, conventional classes and objects, elegant FFI, safe access to mature
mainstream libraries) but, most importantly, F# is the first decent
functional language to really facilitate commerce, i.e. there is a viable
market for libraries written in F# unlike OCaml and Haskell.

You may also be interested in Erlang and Scala.

klohm...@yahoo.de

unread,
Nov 21, 2008, 9:23:20 AM11/21/08
to


==
(module bin
(static
(class class-f64array
v
(offsets::pair-nil (default '(1)))
(dims::pair-nil (default '(1)))
(dim-total::bint (default 1)))))


(define (test a::bint)
(print a))


(define (test2 a::class-f64array)
(print a))

;;; where (erg-avk) is of class-f64array
(test (erg-avk))

(test2 (erg-avk))
==


gives the compile time error: bigloo bin.scm:

==
File "bin.scm", line 281, character 7347:
#(test (erg-avk))
# ^
# *** WARNING:bigloo:toplevel-init
Type error -- `bint' expected, `class-f64array' provided
==

I am not saying that Bigloo is a strict typed Scheme. However, it is
one of the most under rated Schemes out there. And honestly without
Bigloo it's 'type' system I wouldn't want to program in Scheme.


Bigloo is cloesel related to OCaml. However, Ocaml features a horribly
disugusting syntax.

0 new messages