[Haskell-cafe] Beginning of a meta-Haskell [was: An issue with the ``finally tagless'' tradition]

Peter Gammie peteg42 at gmail.com
Thu Sep 24 02:39:29 EDT 2009

Thanks Oleg!


On 24/09/2009, at 3:54 PM, oleg at okmij.org wrote:

> and interpret it several times, as an integer
>> -- testpw :: Int
>> testpw = (unR power) (unR 2) ((unR 7)::Int)
>> -- 128

My type function allows one to remove the '::Int' annotation, which is  
especially useful in situations where you cannot give an annotation  
due to 'show . read'-style ambiguity. Conversely one gives up some  
useful polymorphism (in my case, sometimes it would be nice to have  
multiple boolean types).

Another nit with Oleg's code is that you can only interpret Bool with  
Bool, in the interpreter:

> class QBool repr where
>    true, false :: repr Bool
>    if_ :: repr Bool -> repr w -> repr w -> repr w

If 'repr' is merely a Haskell98-style type constructor, it cannot  
analyse its argument. Hence there are two choices: use the argument  
(Bool) or don't (see the pretty printer). I doubt you could implement  
a very pleasant interpreter using the latter option, but see


if you want to try. Again, using a type function here allows you to  
choose an arbitrary type to represent Bool (and so forth). Trying to  
do this with fundeps is possible but syntactically heavy.


More information about the Haskell-Cafe mailing list