[Haskell-cafe] How to use Template Haskell build Map?

Andy Stewart lazycat.manatee at gmail.com
Mon Sep 7 22:03:04 EDT 2009


Hi all,

I have below instances:

       instance PageViewState DiredViewState where
       instance PageViewState StringViewState where

I can use Language.Haskell.Exts.Parser scan above instances got list:

       typeList :: [Type]
       typeList = [TyCon (UnQual (Ident "DiredViewState")),TyCon (UnQual (Ident "DiredViewState"))]

So question is how to use Template Haskell and above `typeList` build
below `Map` at compile-time? 
       
tagmap = M.fromList [(typeIdOf StringViewState, Exists (Dict :: PageViewStateDict StringViewState))
                    ,(typeIdOf DiredViewState, Exists (Dict :: PageViewStateDict DiredViewState))]
                    
Thanks!

  -- Andy
                    
                    

                    



More information about the Haskell-Cafe mailing list