Re: pseudo-functors in mlb files

Matthew Fluet <[email protected]> Fri, 12 Aug 2016 09:32:23 -0400
Newsgroups gmane.comp.lang.ml.mlton.user
Message-ID <CAMrhFL50jSmxCix_CuXMYUt06-w=BkFJwbPk6ZM3xOeyCXBO5Q@mail.gmail.com>
On Fri, Aug 12, 2016 at 2:40 AM,  <[email protected]> wrote:
> I have a project where the “naïve” solution is to have two mlb files:
>
>     Variation1.sml
>     Subsequent1.sml
>     Subsequent2.sml
>
> And
>
>     Variation2.sml
>     Subsequent1.sml
>     Subsequent2.sml
>
> The Subsequent files depend on bindings made in Variation1 and 2. Clearly, the “right” way to do this would be to have some sort of massive functor that abstracted the Variation signature and generated the Subsequent files. (Alternatively, one functor per Subsequent file, I suppose.)
>
> Given the history of my project, there are lots of Subsequent files (not just 2) and I don’t fancy trying to wrap a functor around them all.  (Perhaps this is not as bad as I am thinking; feel free to tell me I should just do this.)
>
> I first thought that I might be able to have a Subsequent.mlb file that was
>
>     Subsequent1.sml
>     Subsequent2.sml
>
> And that I could then have variation1.mlb:
>
>     Variation1.sml
>     Subsequent.mlb
>
> And variation2.mlb:
>
>     Variation2.sml
>     Subsequent.mlb
>
> But this doesn’t work, and for good reason (Subsequent.mlb is elaborated/checked in isolation).
>
> Is there any good way to get the effect I want?  (In particular, having to repeat Subsequent1.sml .. Subsequent2.sml in both files is yucky.)

You can (ab)use MLB path variables (http://mlton.org/MLBasisPathMap)
to "choose" between variations.  That is, you would have:

project.mlb:
$(VARIATION).sml
Subsequent1.sml
Subsequent2.sml

and then compile with "-mlb-path-var VARIATION Variation1" or
"-mlb-path-var VARIATION Variation2".  At compile time, the MLB path
variables are simply expanded and the resulting MLB is processed, so
you get the effect of two different (nearly identical) MLB files from
the same source.

-- 
You received this message because you are subscribed to the Google Groups "MLton-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
MLton-user mailing list
[email protected]; [email protected]
https://lists.sourceforge.net/lists/listinfo/mlton-user