dynamic types

Richard Uhtenwoldt ru@river.org
Tue, 07 Jan 2003 11:59:01 -0800


Just want to make sure I understand.

There does not exist a Haskell implementation-specific extension which
provides the sort of dynamic type that would allow one to discriminate
at run time between built-in types; right?  eg,

main=do 
    object<-readLn
    case object of   --or some such syntax
        ()->putStrLn "void type detected"
        (a::Integer)->putStrLn "Integer type detected"

For those readers whose prelude is rusty, I quote from the prelude:

   readLn           :: Read a => IO a
   readLn           =  do l <- getLine
                          r <- readIO l
                          return r


And even if the object being discriminated "lacks
polymorphicity", eg, this next, that does not change the answer
to my question; right?

main=do 
    command<-readLn
    let 
        object=case command of
            "Integer"->(5::Integer)
            "Void"->()
    case object of
        ()->putStrLn "void type detected"
        (a::Integer)->putStrLn "Integer type detected"