Tuesday 15 September 2015

Getting associated type synonyms with template Haskell -


What template can detect the associated type synonyms and / or declarations declared in a type square? I expected what I want, but it does not provide all the necessary information This function works to get the typed signature:

 % ghci GHCi, version 7.8.3: http : //www.haskell.org/ghc/ :? For help ... Prelude & gt; - I will insert line break and whitepace for clarity Prelude & gt; - Preface in all GHCI output & gt; : Set -xtemplateHaskell Prelude & gt; Import language Haskell.TH offer language. Haskell.TH & gt; Class C A where F: A -> Int Prelude Language Haskell. PutStrLn $ (stringE show =. & Lt; & quot; Think about something like ') classical (ClassD [] Ghci1.C [PlainTV a_1627398388] [] [SigD Ghci1.f (ForallT [PlainTV a_1627398388] [ClassP Ghci1.C [Conducted A_1627398388]] (App (APT ARTAT (AAPT ARAT) (Corat GHC Tape. INST))) []   

However, an affiliate type for class There is no change in adding synonyms (to change name to up):

  prelog language. Haskell.TH>: Set -SexPemillies prelude A. Haskell.HATA; Category C 'A where one type FA: *; F' :: a -> int prelude language .Haschel putStrLn $ (stringE show =. & Lt; & lt; 'c' Think of something like 'Classical [ClassD] Ghci3.C' [PlainTV a_1627405973] [] [SigD Ghci3.f '(ForallT [PlainTV a_1627405973] [ClassP Ghci3.C' '[a A1627405973]] (appt (appt ArrowT (turn a_1627405973)) (remaining part GHC.Types.Int)))] []   

I know the name of F , I Information can be seen:

  prelude language. Haskell. DT & gt; PutStrLn $ (. StringE show = & lt; & lt; think about the object like 'F') FamilyI (FamilyD TypeFam Ghci3.F [PlainTV a_1627405973] (Bus Start)) []  

but i can not find the name of f in the first place even if i add an example of type class, any about definition in instanced Also do not have the information:

  prelude language. Haskell.TH & gt; Example C '[A] where type F [A] = A; F '= Length prelude language. Haskell .TH & gt; F '"Haskell" 7 offer language. Haskell. 42 :: F [Integer] 42 prelude language. Haskell. DT & gt; PutStrLn $ (stringE show =. & Lt; 'think' about the object 'C') classical (ClassD [] Ghci3.C '[[PlainTV a_1627405973] [] [SigD Ghci3.f' (ForallT [PlainTV a_1627405973] ] [Classp Ghci3.C '' [a.A.627405973]] (appt (appt ArrowT (turn a_1627405973)) (remaining part GHC.Types.Int)))] [instanced [] (appt (remaining part Ghci3.C ') ( Appt ListT (turn a_1627406161))] []]   

If modify will not work, except for manually indexing affiliate type names Is there any alternative solution?

This problem is present in GHC 7.8.3 with the template- Haskel package version 2.9.0.0; This template was also available in GHC 7.4.2 with version 2.7.0.0 of Haschel package. (I was not checking at GHC 7.6, but I think it was also present.) I am interested in solving any version of GHC (in which "this is only in GHC version V ").

This is not implemented because no one requests it.

The strange thing is that TH uses its own AST, which does not follow the AST of the internal compiler. Consequently, any new feature (such as family of related type) is not available automatically by TH. Some people will have to open a ticket and implement it.

For reference: Internal reifyClass function linked type families (this is back by the fifth element of Tupal, see also.)

Technically it should be easy to implement the support of the respective type of family in modify , but most likely it will require backward inconsistent changes in the TH API, e.g. Because its AST affiliate type does not support defaults.

Added: This is now (without API BTW changes) and will probably be available in the next ghc issue.

No comments:

Post a Comment