type-systems

What is the difference between Latent type and Manifest type?

Could someone give me a clear distinction between latent and manifest type system? ...

Duck typing, must it be dynamic? [CW]

Wikipedia currently says about duck-typing: In computer programming with object-oriented programming languages, duck typing is a style of dynamic typing in which an object's current set of methods and properties determines the valid semantics, rather than its inheritance from a particular class or implementation of a sp...

Is my understanding of type systems correct?

The following statements represent my understanding of type systems (which suffers from too little hands-on experience outside the Java world); please correct any errors. The static/dynamic distinction seems pretty clear-cut: Statically typed langauges assign each variable, field and parameter a type and the compiler prevents assignme...

Java generics + static factory methods = [panic]

Hello, everyone! I thought, I would understand Java generics by now. But now I'm helpless again. I have a generic class where a c-tor constructs correctly-typed instance, while a static factory method produces a type mismatch. Please look at the following code: public class _GenericFactoryMethods { public final static class DemoCl...

Are there any languages that are dynamically typed but do not allow weak typing?

For example, adding a (previously undeclared) int and a string in pseudocode: x = 1; y = "2"; x + y = z; I've seen strongly typed languages that would not allow adding the two types, but those are also statically typed, so it's impossible to have a situation like above. On the other hand, I've seen weakly typed languages that allow th...

What is meant by Scala's path-dependent types?

I've heard that Scala has path-dependent types. It's something to do with inner-classes but what does this actually mean and why do I care? ...

Does C# have an equivalent to Scala's structural typing?

In Scala, I can define structural types as follows: type Pressable = { def press(): Unit } This means that I can define a function or method which takes as an argument something that is Pressable, like this: def foo(i: Pressable) { // etc. The object which I pass to this function must have defined for it a method called press() that ...

Returning the same type the function was passed

I have the following code implementation of Breadth-First search. trait State{ def successors:Seq[State] def isSuccess:Boolean = false def admissableHeuristic:Double } def breadthFirstSearch(initial:State):Option[List[State]] = { val open= new scala.collection.mutable.Queue[List[State]] val closed = new scala.collection.m...

Extending the .NET type system so the compiler enforces semantic meaning of primitive values in certain cases

I'm working developing a system right now that deals with lots of conversions between semantically different values that have the same primitive .NET type (double/string/int). This means that it's possible to get confused about which 'semantic type' you are using, either by not converting or converting too many times. Ideally I'd like ...

Haskell Weird Kinds

When I was experimenting with Haskell kinds, and trying to get the kind of ->, and this showed up: $ ghci ... Prelude> :k (->) (->) :: ?? -> ? -> * Prelude> Instead of the expected * -> * -> *. What are the ?? and ? things? Do they mean concrete types or "kind variables"? Or something else? ...

Functional Programming and Type Systems

I have been learning about various functional languages for some time now including Haskell, Scala and Clojure. Haskell has a very strict and well-defined static type system. Scala is also statically typed. Clojure on the other hand, is dynamically typed. So my questions are What role does the type system play in a functional language...

.NET Settings File Available Types

When modifying a .NET settings file, I'm given a choice of types for a setting. However, not all of the types accessible by my project appear, even in the 'Browse' window. What determines if a type can be used for a setting file setting? I have a type I created that I would like to be able to save, and I want to know what I need to cha...

Typedefs and template specialization

Consider this code: typedef int type1; typedef int type2; template <typename> struct some_trait; template <> struct some_trait<type1> { static const int something=1; }; template <> struct some_trait<type2> { static const int something=2; }; It fails because what the compiler sees is two specializations of some_trait<int>. ...

Is there a programming language where types can be parametrized by values?

Parametrized types such as C++ templates are a nice thing, but most of the time they can only be parametrized by other types. However there is a special case in C++ where it is possible to parametrize a template by an integer. For example, fixed-length arrays are a typical use case: template<typename T, int SIZE> class FixedArray { ...

F# type functions and a [<GeneralizableValue>] attribute

What is the difference between this two F# type functions: let defaultInstance1<'a when 'a:(new: unit->'a)> = new 'a() [<GeneralizableValue>] let defaultInstance2<'a when 'a:(new: unit->'a)> = new 'a() ...

The type system in Scala is Turing complete. Proof? Example? Benefits?

There are claims that Scala's type system is Turing complete. My questions are: Is there a formal proof for this? How would a simple computation look like in the Scala type system? Is this of any benefit to Scala - the language? Is this making Scala more "powerful" in some way compared languages without a Turing complete type system? ...