<div dir="ltr">Hi,<div>We tried to do something similar a few years ago and couldn't get a nice solution for this.</div><div>We ended up just requiring the user code to define a binding with a hard-coded name as a struct containing everything. I got the impression that the plugin ran too late in the pipeline to load new modules, so we couldn't add an import for the module we wanted.</div><div><br></div><div><a href="https://github.com/DDCSF/repa/blob/master/icebox/abandoned/repa-plugin/Data/Array/Repa/Plugin/Primitives.hs#L142">https://github.com/DDCSF/repa/blob/master/icebox/abandoned/repa-plugin/Data/Array/Repa/Plugin/Primitives.hs#L142</a></div><div><a href="https://github.com/DDCSF/repa/blob/master/icebox/abandoned/repa-plugin/test/01-Simple/Main.hs#L11">https://github.com/DDCSF/repa/blob/master/icebox/abandoned/repa-plugin/test/01-Simple/Main.hs#L11</a><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 18 Nov 2016 at 19:36 J. Stutterheim <<a href="mailto:j.stutterheim@me.com">j.stutterheim@me.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br class="gmail_msg">
<br class="gmail_msg">
I'm looking for a way to add my own wired-in package/module/type class for use in a core-to-core plugin.<br class="gmail_msg">
<br class="gmail_msg">
My first challenge is to identify the type class that I want to find. I have the following code:<br class="gmail_msg">
<br class="gmail_msg">
myPkgUnitId :: UnitId<br class="gmail_msg">
myPkgUnitId = fsToUnitId (fsLit "mypackage")<br class="gmail_msg">
<br class="gmail_msg">
mkMyModule :: FastString -> Module<br class="gmail_msg">
mkMyModule m = mkModule myPkgUnitId (mkModuleNameFS m)<br class="gmail_msg">
<br class="gmail_msg">
myModule :: Module<br class="gmail_msg">
myModule = mkMyModule (fsLit "My.Module")<br class="gmail_msg">
<br class="gmail_msg">
myClassName :: Name<br class="gmail_msg">
myClassName = clsQual myModule (fsLit "MyClass") myClassKey<br class="gmail_msg">
<br class="gmail_msg">
myClassKey :: Unique -- How do I get this?<br class="gmail_msg">
<br class="gmail_msg">
Here the missing piece is the myClassKey. Looking at how this is done for, e.g., the Monad class:<br class="gmail_msg">
<br class="gmail_msg">
monadClassKey :: Unique<br class="gmail_msg">
monadClassKey = mkPreludeClassUnique 8<br class="gmail_msg">
<br class="gmail_msg">
we see that it has a hard-coded unique identifier. Is there a way to do the same for my own type class? Or to somehow find the Unique key dynamically?<br class="gmail_msg">
<br class="gmail_msg">
The second challenge is more or less the same in that I want to identify a member of MyClass:<br class="gmail_msg">
<br class="gmail_msg">
myFunMName :: Name<br class="gmail_msg">
myFunMName = varQual myModule (fsLit "myFun") myFunMClassOpKey<br class="gmail_msg">
<br class="gmail_msg">
myFunMClassOpKey :: Unique -- How do I get this?<br class="gmail_msg">
<br class="gmail_msg">
Again, the identifier is hard-coded for, e.g., ">>=".<br class="gmail_msg">
<br class="gmail_msg">
Any insights will be much appreciated.<br class="gmail_msg">
<br class="gmail_msg">
Best regards,<br class="gmail_msg">
<br class="gmail_msg">
Jurriën_______________________________________________<br class="gmail_msg">
Haskell-Cafe mailing list<br class="gmail_msg">
To (un)subscribe, modify options or view archives go to:<br class="gmail_msg">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" class="gmail_msg" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="gmail_msg">
Only members subscribed via the mailman list are allowed to post.</blockquote></div>