No special magic. Just make sure you get the th-new branches of ghc,
libraries/template-haskell, and testsuite.

If you hit any snags let me know---happy to help you get running.

Geoff

On 05/17/2013 07:12 PM, Jacques Carette wrote:
Fantastic!  I will definitely  be trying it out early next week.
>
> Are there any special instructions regarding how to compile this
> branch?  I will work on adding test cases, which would be translations
> of larger metaocaml programs.
>
> Jacques
>
> On 13-05-16 11:21 AM, Geoffrey Mainland wrote:
>> I have pushed a new branch, th-new, that partially implements the
>> proposal outlined in Simon PJ's "New directions for Template Haskell"
>> post at:
>>
>> http://hackage.haskell.org/trac/ghc/blog/Template%20Haskell%20Proposal
>>
>> The main missing features are top-level pattern splices and local
>> declaration splices.
>>
>> Typed expression quotations and typed expression splices *are*
>> implemented. Syntax is as in Simon's original proposal: [|| ||] for
>> typed expression brackets and $$(...) for typed expression splices. One
>> can now write:
>>
>> power :: Int -> TExp (Int -> Int)
>> power n = [|| \x -> $$(go n [|| x ||]) ||]
>> where
>> go :: Int -> TExp Int -> TExp Int
>> go 0 x = [|| 1 ||]
>> go n x = [|| $$x * $$(go (n-1) x) ||]
>>
>> In fact, one can even write:
>>
>> power :: Num a => Int -> TExp (a -> a)
>> power n = [|| \x -> $$(go n [|| x ||]) ||]
>> where
>> go :: Num a => Int -> TExp a -> TExp a
>> go 0 x = [|| 1 ||]
>> go n x = [|| $$x * $$(go (n-1) x) ||]
>>
>> Writing the following
>>
>> f :: TExp Char -> TExp Integer
>> f x = [|| $$x * 3 ||]
>>
>> gives the error
>>
>> Main.hs:28:7:
>> Couldn't match type ‛Char’ with ‛Integer’
>> Expected type: TExp Integer
>> Actual type: TExp Char
>> In the Template Haskell quotation [|| $$x * 3 ||]
>> In the expression: [|| $$x * 3 ||]
>> In an equation for ‛f’: f x = [|| $$x * 3 ||]
>>
>> The th-new branch of ghc has accompanying branches for template-haskell
>> and testsuite, both named th-new. These are mirrors of my local branch,
>> and I reserve the right to rebase them :). That said, please do try it
>> out!
>>
>> Geoff

_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://www.haskell.org/mailman/listinfo/ghc-devs

Reply via email to