type-systems

Haskell's algebraic data types

I'm trying to fully understand all of Haskell's concepts. In what ways are algebraic data types similar to generic types, e.g., in C# and Java? And how are they different? What's so algebraic about them anyway? I'm familiar with universal algebra and its rings and fields, but I only have a vague idea of how Haskell's types work. ...

Dynamic type languages versus static type languages

What are the advantages and limitations of dynamic type languages compared to static type languages? See also: whats with the love of dynamic languages (a far more argumentative thread...) ...

Language features to implement relational algebra

I've been trying to encode a relational algebra in Scala (which to my knowlege has one of the most advanced type systems) and just don't seem to find a way to get where I want. As I'm not that experienced with the academic field of programming language design I don't really know what feature to look for. So what language features would...

What is a type and effect system?

The Wikipedia artcile on Effect system is currently just a short stub and I've been wondering for a while as to what is an effect system. Are there any languages that have an effect system in addition to a type system? What would a possible (hypothetical) notation in a mainstream language, that you're familiar, with look like with e...

What is an Existential Type?

I read through the wikipedia entry on this. I gathered that they're called existential types because of the existential operator (∃). I'm not sure what the point of it is, though. What's the difference between T = ∃X { X a; int f(X); } and T = ∀x { X a; int f(X); } ...

Are there well known algorithms for deducing the "return types" of parser rules?

Given a grammar and the attached action code, are there any standard solution for deducing what type each production needs to result in (and consequently, what type the invoking production should expect to get from it)? I'm thinking of an OO program and action code that employs something like c#'s var syntax (but I'm not looking for som...

Typed FP: Tuple Arguments and Curriable Arguments

In statically typed functional programming languages, like Standard ML, F#, OCaml and Haskell, a function will usually be written with the parameters separated from each other and from the function name simply by whitespace: let add a b = a + b The type here being "int -> (int -> int)", i.e. a function that takes an int and return...

erlang type system

hello I've been scrounging around the web looking for various typing practices of Erlang programs and there seem to be a few... although its somewhat difficult to find a solid source of info namely Im looking for practical info about: 1."-specs" - this one looks pretty attractive. a few places mention that the functions that have an ass...

What is a type inferencer?

Does it only exist in statically typed languages? And is it only there when the language is not strongly typed (i.e. does Java have one)? Also, where does it belong - in the compilation phase assuming it's a compiled language? In general, are the rules when the type is ambiguous dictated by the language specification or left up to the i...

What are the deficiencies of the Java/C# type system?

Its often hear that Haskell(which I don't know) has a very interesting type system.. I'm very familiar with Java and a little with C#, and sometimes it happens that I'm fighting the type system so some design accommodates or works better in a certain way. That led me to wonder... What are the problems that occur somehow because of def...

Why is PartialFunction <: Function in Scala?

In Scala, the PartialFunction[A, B] class is derived from type Function[A, B] (see Scala Reference, 12.3.3). However, this seems counterintuitive to me, since a Function (which needs to be defined for all A) has more stringent requirements than a PartialFunction, which can be undefined at some places. The problem I've came accross was t...

Scala's existential types

A bit more specific than this question, can someone tell me what is the difference between Scala's existential types and Java's wildcard, prefereably with some illustrative example? In everything I've seen so far, they seem to be pretty equivalent. Edit: A few references. Martin Odersky mentions them; Google's top hit for my question ...

What are the limits of type inference?

What are the limits of type inference? Which type systems have no general inference algorithm? ...

What are the limits of type checking and type systems?

Type systems are often criticised, for being to restrictive, that is limiting programming languages and prohibiting programmers to write interesting programmes. Chris Smith claims: We get assurance that the program is correct (in the properties checked by this type checker), but in turn we must reject some interesting programs. a...

Explicit type recursion in F#

Inspired by this question: Is explicit type recursion possible in F#? type 'a Mu = In of 'a Mu 'a let unIn (In x) = x This code unfortunatly gives "Type parameter cannot be used as type constructor. Remarks: This construct is used in the paper Functional Programming with Overloading and Higher-Order Polymorphism, for example. Exam...

What uses have you found for higher-rank types in Haskell?

Higher rank types look like great fun. From the Haskell wikibook comes this example: foo :: (forall a. a -> a) -> (Char,Bool) foo f = (f 'c', f True) Now we can evaluate foo id without the compiler exploding. This example is quickly followed in the book by the real-world example I have seen in a few other places: the ST monad and runS...

From Static Typing to Dynamic Typing

I have always worked on staticly typed languages (c/c++,java). For the poast months i have been playing with clojure and i really like it. One thing i am worried about is, say that i have a windows that takes 3 modules as arguments and along the way requirements change and i need to pass another module to the function. I just change the ...

Bitflag enums in C++

Using enums for storing bitflags in C++ is a bit troublesome, since once the enum values are ORed they loose their enum-type, which causes errors without explicit casting. The accepted answer for this question suggests overloading the | operator: FlagsSet operator|(FlagsSet a, FlagsSet b) { return FlagsSet(int(a) | int(b)); } ...

Suggestions needed: alternative to overloading "is" and "as" operators in .NET

I hope this question isn't deemed too subjective - I don't really expect a definitive answer, but I hope that everyone's opinion will at least help me form my own. I'm implementing a custom type system, that is a superset of the classical OOP type system. In this type system, object instances may be combined at runtime to form new insta...

What are the differences and similarities of Scala and Haskell type systems?

How to explain Scala's type system to a Haskell expert? What examples show Scala's advantages? How to explain Haskell's type system to an advanced Scala practitioner? What can be done in Haskell that can't be done in Scala? ...