[GHC] #13054: Generating unique names with template haskell
GHC
ghc-devs at haskell.org
Mon Jan 2 06:51:03 UTC 2017
#13054: Generating unique names with template haskell
-------------------------------------+-------------------------------------
Reporter: tim-m89 | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Template | Version: 8.0.1
Haskell |
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
I need to use template haskell to generate a few instances where those
instances each use a foreign function obtained from a particular
{{{FunPtr}}}.
As far as I'm aware, the only clean way to do this requires top level
declarations of the form:
{{{foreign import ccall "dynamic" makeFun1 :: FunPtr Foo -> Foo}}}
If there was either:
* Another way to do this without requiring top level named declarations.
* The possibility to use these within a where clause (template haskell
would suggest so given that it lets you use {{{Dec}}} within a
{{{where}}}).
Then I'd be fine probably be fine without names.
I've tried using {{{newName}}} as it apparently generates fresh names but
I cannot get it work for me.
I've put a copy of the test case [https://gitlab.com/tim-m89/hs-th-name-
issue here]. I compile with {{{stack build --ghc-options="-ddump-splices
-ddump-to-file"}}} and the error is:
{{{
th-name-issue/app/Main.hs:7:12: error:
Multiple declarations of ‘makeFun’
Declared at: app/Main.hs:7:12
app/Main.hs:7:12
}}}
Then I run {{{gvim .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/th-
name-issue-exe/th-name-issue-exe-tmp/app/Main.dump-splices}}}
And can see:
{{{
app/Main.hs:7:12-25: Splicing declarations
template-haskell-2.11.0.0:Language.Haskell.TH.Quote.quoteDec
importGen " stuff here "
======>
foreign import ccall safe "dynamic" makeFun_a3pc
:: GHC.Ptr.FunPtr (Foreign.C.String.CString -> IO ())
-> Foreign.C.String.CString -> IO ()
foreign import ccall safe "dynamic" makeFun_a3pd
:: GHC.Ptr.FunPtr (Foreign.C.String.CString -> IO ())
-> Foreign.C.String.CString -> IO ()
}}}
Which suggests that I did manage to get unique names after all, so I don't
know why it didn't compile??
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13054>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list