<div dir="ltr"><span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">plugins is outdated because the functionality is now in ghc-api and exposed in more convenient ways by the hint package. (Some parts of it were always in ghc-api; plugins provided the parts it originally didn't, notably safe unloading of modules.) That said, dynamic loading is something of a bad fit for Haskell; often, the easiest way to do this is to build a new program including the module and run it in place of the original. See for example how xmonad configuration works. The dyre package also provides a form of this.</span><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">Another way to do this is to use programs instead of modules, and the Core driver provides the UI and plumbs the programs together with sockets or other IPC mechanisms. This is slower in general. (Either way requires some form of serialization and marshaling of data, so you will have that overhead regardless.)</div><br></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Jul 22, 2018 at 11:27 AM Marc Busqué <<a href="mailto:marc@lamarciana.com">marc@lamarciana.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi there,<br>
<br>
I'm currently programming my first non toy project in Haskell. I come from Ruby<br>
background, where everything is possible no matter how much entropy the<br>
universe gains after you finish your work, so I'm still not sure how to do<br>
certain things without this side-effect :)<br>
<br>
I'll try to be concise. My idea is that the project would consist of several<br>
different Haskell packages. The central one, call it Core, would define a<br>
certain data type (with info about certain URLs). Other packages would define<br>
each one an strategy to do something with that data type (processing the URL<br>
info). Each strategy would have its own dependencies, and as a user probably<br>
won't need all of the strategies, I would like to keep them in separated<br>
packages so she or he has no need to download the unneeded stuff.<br>
<br>
The problem is that Core should act as the central dashboard, whether through a<br>
CLI or even a web frontend. For example, in the CLI case, I would like to be<br>
able to install Core package along with package StrategyA and package StrategyB<br>
and then do something like the following:<br>
<br>
``` <br>
bash> core --action=fetch --strategy=A<br>
bash> core --action=fetch --strategy=B<br>
```<br>
<br>
Two generic ideas come to my mind but I don't know how to translate them<br>
to Haskell:<br>
<br>
- Infer module name from the `--strategy` argument and call it dynamically.<br>
However, as far as I know, in Haskell modules are not first class citizens,<br>
so no way I can dynamically call them. I have read something to achieve this<br>
through Template Haskell or through outdaded<br>
[plugins](<a href="http://hackage.haskell.org/package/plugins" rel="noreferrer" target="_blank">http://hackage.haskell.org/package/plugins</a>) package, but I'm not<br>
sure whether the need is the same and anyway it seems quite unnatural to<br>
Haskell (I would not like to go against it, but to learn to do thing in its<br>
way).<br>
<br>
- Define from Core some kind of global list where strategy packages can<br>
register a map between CLI argument value and a defined instance of the core<br>
data type. But, again, how to do global things in Haskell (and I would prefer<br>
not to need external tools like RDBMS, filesystem or whatever)? And, anyway,<br>
surely I don't want to do this because concurrency and everything...<br>
<br>
Any idea?<br>
<br>
Thanks in advance!<br>
<br>
Marc Busqué<br>
<a href="http://waiting-for-dev.github.io/about/" rel="noreferrer" target="_blank">http://waiting-for-dev.github.io/about/</a>_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>