[Haskell-cafe] a bunch of newbie questions

Janis Voigtlaender voigt at tcs.inf.tu-dresden.de
Fri Aug 4 06:14:09 EDT 2006


Imam Tashdid ul Alam wrote:
> what's the difference between data and co-data
> exactly?  or between inductive data types and
> co-inductive data types?

In Haskell there is no such difference, as inductive and coinductive 
types coincide in the semantic setting in which Haskell is usually 
interpreted.

If there were a difference, that is, if we interpret Haskell minus 
general recursion in a somewhat simpler semantic setting, then data 
types would contain inly finite values, whereas codata types could also 
contain infinite values.

> can you give me some
> reference points that explain these?

Papers by Uustalu and Vene might be a good start. Watch out for 
corecursion and coalgebras.

>>(read "56")::Integer 
> 
> 
> does it in fact pass the type (Integer) to the
> function (read)?

No, it just says that the result of read should be an Integer.

> I guess what we want is for the
> (Integer) implementation of the (read) function to
> evaluate, not really to cast the value of (read)
> function to (Integer).

Exactly. And that's what is happening. Based on the information provided 
when giving the result type.

> in the regex libraries, (~=)
> cast this way results in completely different things
> altogether, should type classes have namespaces
> associated with them? somewhat like Integer.read "56"?

I don't think that we need this.

> this way of selecting the intended implementation,
> does it work without trouble with multiparameter type
> classes as well?

Yes, as long as enough type information is provided for the typechecker 
to decide what is the correct instance to use. One way of reducing the 
amount of information needed is using functional dependencies.

> theoretically is it possible to do a strictness
> analysis without any help from the programmer?

Yes, such analyses exist, and are implemented in GHC, for example. They 
are just approximative, and cannot be exact by computability reasons.

Ciao, Janis.

-- 
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:voigt at tcs.inf.tu-dresden.de


More information about the Haskell-Cafe mailing list