
Read http://okmij.org/ftp/Haskell/types.html to gain insight into a host of different ways in which the powerful Haskell type system can be (ab)used to get, for instance -
polyvariadic functions (which take a variable number of arguments with potentially different types)
functions with genuine keyword arguments,
static array bounds checking,
automatically reifying a type to yield a function with the desired properties (using only the haskell typechecker. No external tools/extensions are needed because Haskell already has extensive reflexive properties),
strongly typed heterogenous collections,
and a whole bunch of other stuff that will blow your mind!
The following code causes Haskell 98 to give a Segmentation Fault!!!
module C whereimport Data.Typeableimport Data.Maybenewtype W a = W{unW :: a}instance Typeable (W a) where typeOf _ = typeOf ()bad_cast x = unW . fromJust . cast $ W x-- inferred type: bad_cast :: a -> btest1 = bad_cast True ++ ""
Sad but true...
No comments:
Post a Comment