Hi,
I am comparing some aspects of Haskell with Java.
Below is a simple Haskell program with a sub-class.
It is followed my attempt to code the same concepts in Java.
Two questions:
1) Are the two examples close enough? (very subjective)
2) In this example, what are the advantages of the Haskell type checking over the Java type checking?
3) Are there more general advantages of Haskell type checking over Java type checking?

Regards,
Pat



==== Haskell program===
data C
data D

class A t where
instance A C where
instance A D where


class A t => B t where
instance B C where
instance B D where


=====Java Program===
import java.lang.Class;

interface A<T> {}
class A_INSTANCE<T> implements A<T> {}


interface B<T> extends A<T>{}
class B_INSTANCE<T> implements B<T> {}



class C {}
class D {}

public class DEMO1 {
public static void main(String args[]) {


A_INSTANCE<C> ac = new A_INSTANCE<C>();
A_INSTANCE<D> ad = new A_INSTANCE<D>();
B_INSTANCE<C> bc = new B_INSTANCE<C>();
B_INSTANCE<D> bd = new B_INSTANCE<D>();

System.out.println("Object's Class name =>"+  ac.getClass().getName());
System.out.println("Object's Class name =>"+  ad.getClass().getName());
System.out.println("Object's Class name =>"+  bc.getClass().getName());
System.out.println("Object's Class name =>"+  bd.getClass().getName());

  }
}


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to