[Haskell-cafe] run-time type testing in haskell?

Stefan O'Rear stefanor at cox.net
Sat Apr 28 09:10:16 EDT 2007

On Sat, Apr 28, 2007 at 02:06:21PM +0100, Eric wrote:
> In imperative languages one can test the type of a variable and downcast 
> if necessary. Here's an example in Pseudojava:
> T v := ... ;
> if (v instanceof T') T' v' := (T')v
> Is it possible to do something like this in Haskell?

Possible, yes.  Usually a good idea - no.

Look at the Data.Typeable and Data.Dynamic modules in the standard
hierarchal libraries. 


More information about the Haskell-Cafe mailing list