Cactus

Type inference for CLazy

22 January 2009 (programming language lisp) (1 comment)

CLazy now features Hindley-Milner type inference, the type calculus all the cool guys use. For example, given the following recursive definition of map:

(defun map (f nil)
    nil)
(defun map (f (cons x xs))
    (cons (f x) (map f xs)))

the type inference engine of CLazy correctly reconstructs the following type signature:

map :: (fun (fun a b) (list a) (list b))

Still to come: virtual functions like Haskell's typeclasses. The plan is to define abstract functions like (+ a) :: (fun a a a) and collect requirements for functions in the form of "this function has type (fun a b) as long as an overload for (+ a) exists".


« λ: A tiltott kalkulus 
All posts
 CLazy interpreter and compiler »


bkil (http://bkil.blogspot.com/) 2009-08-07 22:22:20

Hey, that's a real neat feature you've got there! A bit more tweaking and you'll arrive at an implementation of Haskell... :D Though personally I like Haskell's syntax better, because of it's clarity. Have you considered plugging in a user-friendly preprocessor and parser sometime in the future? :)

However, be warned that the name "Alef" is considered disadvantageous both because of its generality (like J, K, Q, Self, Nice, Joy, ...) and the fact that it's already taken!

http://en.wikipedia.org/wiki/Alef_(programming_language)