Typeproviders for Modules / Lenses

60 views
Skip to first unread message

Robert Kuzelj

unread,
Jul 6, 2016, 4:02:14 AM7/6/16
to F# Discussions
Hi,

Is there a type provider out there that could create lenses for any given module (or at least a type)

for example

type FooLenses = LensService<FooModule>
//or at least
type FooLenses = LensService<FooModule.SomeDU>
//as I dont know if a "module" is recognized as a type

and if not is it even possible to write such thing?

Rob

Andrew Cherry

unread,
Jul 6, 2016, 6:32:02 AM7/6/16
to fsharp-o...@googlegroups.com
There isn't one as it stands (that I know of - usual caveat). In terms of possibility - the last time I checked it wasn't really. In theory you could do something which would generate types from types in another assembly, but not from types in the same assembly due to the stage at which type provider code runs (probably a gross oversimplification - forgive the ways in which that's wrong).

It would be great to have something like that - but at the moment I don't think it's possible in a simple and usable way. 

Would love for someone to show me I'm wrong though!

A.

--
--
To post, send email to fsharp-o...@googlegroups.com
To unsubscribe, send email to
fsharp-opensou...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensou...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mauricio Scheffer

unread,
Jul 6, 2016, 6:38:40 AM7/6/16
to fsharp-o...@googlegroups.com
I have entertained the idea of implementing this some time ago... definitely not easy, but I think the MixinProvider ( https://github.com/pezipink/MixinProvider ) could be used as a building block / base for this since it's pretty much a macro facility which is what's needed here.

Cheers,
Mauricio



--
Mauricio

Andrew Cherry

unread,
Jul 6, 2016, 6:49:10 AM7/6/16
to fsharp-o...@googlegroups.com
I had forgotten the mixin provider as I'd never seriously considered it for "production" work, but Ross would probably kill me for saying so!

Ross McKinlay

unread,
Jul 6, 2016, 7:36:49 AM7/6/16
to fsharp-o...@googlegroups.com
Yeah, whilst the Mixin TP can do it, you should probably look at a more specialized solution as the Mixin TP is very general.  

I would recommend looking at the RouteProvider (https://github.com/isaksky/RouteProvider) which is based off the Mixin TP's Injection mode.  It takes a literal string parameter of routes and writes code to a file which you include in your project.  You could do a similar thing, using the fschecker to look at your module(s) and produce code by analysing the ast. 

Or you could just, you know, write a normal code generator, but where's the fun in that :)

Ross

Don Syme

unread,
Jul 6, 2016, 9:57:30 AM7/6/16
to fsharp-o...@googlegroups.com

Andrew Cherry

unread,
Jul 6, 2016, 11:42:32 AM7/6/16
to fsharp-o...@googlegroups.com
That's what I had in mind with my first reply. I've upvoted that as much as possible, but as noted it's non-trivial! It would be a potentially excellent improvement to TPs when/if landed though.

Steven Taylor

unread,
Nov 2, 2016, 6:54:37 AM11/2/16
to fsharp-o...@googlegroups.com
We explored this idea too + went as far as digging into the implementation.  There are some excellent ways to piggyback off of machinery maintained by big teams targeting the CLR, but not necessarily using F#. 

-Steven


 

--

Mauricio

 

--
--
To post, send email to fsharp-opensource@googlegroups.com


To unsubscribe, send email to


For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.

To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensource+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--
--
To post, send email to fsharp-opensource@googlegroups.com


To unsubscribe, send email to


For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.

To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensource+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--
--
To post, send email to fsharp-opensource@googlegroups.com


To unsubscribe, send email to


For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.

To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensource+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--
--
To post, send email to fsharp-opensource@googlegroups.com


To unsubscribe, send email to


For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.

To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensource+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--
--
To post, send email to fsharp-opensource@googlegroups.com


To unsubscribe, send email to


For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.

To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensource+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.


--
--
To post, send email to fsharp-opensource@googlegroups.com

To unsubscribe, send email to

For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensource+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
--
To post, send email to fsharp-opensource@googlegroups.com

To unsubscribe, send email to

For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensource+unsubscribe@googlegroups.com.

Greg Young

unread,
Nov 2, 2016, 9:53:11 AM11/2/16
to fsharp-o...@googlegroups.com
It could certainly be done via cecil no?

On Wed, Jul 6, 2016 at 11:31 AM, Andrew Cherry <and...@xyncro.com> wrote:
--
Studying for the Turing test
Reply all
Reply to author
Forward
0 new messages