[feature-proposal] Type-class for unary constraint with covariance support

41 views
Skip to first unread message

Alois Cochard

unread,
Jul 2, 2012, 3:55:16 PM7/2/12
to shapel...@googlegroups.com
Hi folks,

Here is a variant of the already existing UnaryTCConstrain type class adding covariance support:

I finally don't use this one to design my DSLs but still think it could be useful in certain specific case, and has I wrote it I wanted to share it with you.

Not much to say about this one, it's basically same pattern as for Natural Transformation with covariance support but for ... UnaryTCConstrain ;)

I'm really bad at finding good names for such abstraction, so your propositions are more than welcome!

That's all for now :)

Cheers

Miles Sabin

unread,
Jul 3, 2012, 4:11:02 AM7/3/12
to shapel...@googlegroups.com
On Mon, Jul 2, 2012 at 8:55 PM, Alois Cochard <alois....@gmail.com> wrote:
> Hi folks,
>
> Here is a variant of the already existing UnaryTCConstrain type class adding
> covariance support:
> https://github.com/aloiscochard/shapeless/commit/6e6924191a3bd502f12a1397776e90df0205d90e
>
> I finally don't use this one to design my DSLs but still think it could be
> useful in certain specific case, and has I wrote it I wanted to share it
> with you.
>
> Not much to say about this one, it's basically same pattern as for Natural
> Transformation with covariance support but for ... UnaryTCConstrain ;)
>
> I'm really bad at finding good names for such abstraction, so your
> propositions are more than welcome!

As I said with CoNatTRel, I'm not completely convinced that we need
additional support for variance beyond the fact that HLists are
themselves already covariant. Can you show us a motivating example for
this ... your test isn't, BTW, UnaryTCConstraint would distinguish the
two cases in exactly the same way.

Cheers,


Miles

--
Miles Sabin
tel: +44 7813 944 528
skype: milessabin
gtalk: mi...@milessabin.com
g+: http://www.milessabin.com
http://twitter.com/milessabin

Alois Cochard

unread,
Aug 4, 2012, 6:12:48 AM8/4/12
to shapel...@googlegroups.com
Same remark as for last one,

UnaryTCConstrain won't accept a HList with a TC of Some, if the TCConstrain is Option.

If you change the test to use UnaryTCConstrain it won't compile (what I seen during my test, maybe I should give it an other try...).

BTW, I created TCConstrain as part of my workflow, but at the end I use only the Natural Transformation as they are adding the constrain too.

So it's probably not useful to have only constrain, as you said you'll probably end using Mapper/MapperAux *OR* a Natural transformation, I don't see a use case where TCConstrain alone are usefull.

Still think covariance support is usefull.

Cheers
Reply all
Reply to author
Forward
0 new messages