[erlang-questions] Erlang again!

Masklinn <>
Fri Jul 23 13:58:38 CEST 2010


On 2010-07-23, at 13:35 , Jesper Louis Andersen wrote:
> On Thu, Jul 22, 2010 at 7:08 PM, Masklinn <> wrote:
>> That's a big advantage of haskell and its strong typing: hoogle[0] lets you search functions by type. In this case you can search for [a] -> [b] -> [c] (a function taking a list of 'a's, a list of 'b's and returning a list of 'c's) and the first result is zipWith[1].
> 
> (Detail aside: The typing terminology is not set in stone. When you
> write "strong typing" I am going to assume you mean that a program can
> be determined well-typed at compile time by a static semantics on the
> abstract syntax tree of the program. Other people, myself included,
> call this property "static typing" and we reserve the "strong typing"
> to mean: There are no unchecked run-time type errors. So the program
> will never segfault. end-of-aside)
You are entirely correct and I stand red-faced, and dumbfounded I could have written "strong" here when I definitely thought "static".

> Right now, you are right. There is no hoogle tool for Erlang.
> Theoretically, I think you are wrong and here is why: Kostis Sagonas
> has recently added -spec() contracts to the Erlang system which allows
> you to gain some of the advantages of static typing while still
> retaining the dynamic properties of Erlang. In principle, it should be
> possible to write a hoogle-like system for Erlang on top of these
> -spec() contracts and gain exactly the same kind of documentation
> lookup.
Yes, but as you mentioned it only works for -spec. And I doubt -spec is as expressive as Haskell's type system either. Theoretically, hoogle can extract types even from fully unspecified (inferred) functions, which would correspond to -spec-less functions in Erlang, and make those searchable as well.

> Also, simply having the type specification for a given function is not
> always enough. Let me draw up a simple example: Haskells iteratee
> library by John W. Lato.
Oh definitely not and I apologize if it came across that way. I mostly meant that an expressive type system can provide great insight as to the purpose and behavior of a function.


More information about the erlang-questions mailing list