[Haskell-cafe] haskell and reflection

Jules Bean jules at jellybean.co.uk
Tue Sep 11 10:47:56 EDT 2007


Greg Meredith wrote:
> Haskellians,
> 
> Am i wrong in my assessment that the vast majority of reflective 
> machinery is missing from Haskell? Specifically,
> 
>     * there is no runtime representation of type available for
>       programmatic representation
>     * there is no runtime representation of the type-inferencing or
>       checking machinery
>     * there is no runtime representation of the evaluation machinery
>     * there is no runtime representation of the lexical or parsing
>       machinery 


As far as they go, those are true.

Haskell compiler are permitted to erase types and GHC does so. There is 
no need to check types at runtime; that's the point of the system! There 
is no evaluator, or parser, built in to the standard libraries. (The 
lexer, or a version of it, is embedded in actual fact but that's not 
very exciting).

However, one should not draw too strong negative conclusions from this. 
It is possible to get suprisingly far with more powerful, more typesafe 
techniques without surrendering the the pure dynamism of languages that 
lack compile-time guarantees. Deriving Typeable and Data is one tool 
which is useful.

It is quite possible to embed a haskell compiler, see hs-plugins.

Jules


More information about the Haskell-Cafe mailing list