tag:blogger.com,1999:blog-2744072865491516720.post8224383235054475123..comments2023-05-03T06:35:33.259-04:00Comments on Higher Logics: Abstracting over Type Constructors using Dynamics in C#Sandro Magihttp://www.blogger.com/profile/05446177882449578817noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-2744072865491516720.post-49100157816320850772012-02-04T01:02:38.963-05:002012-02-04T01:02:38.963-05:00It's a little hard to describe sharing constra...It's a little hard to describe sharing constraints since .NET doesn't have anything exactly comparable. These constraints are a way to control the propagation of type information between modules that would otherwise be completely encapsulated.<br /><br />The closest analogue I can think of are interface specifications on type constraints. Consider:<br /><br />void Foo<T>(T afoo) where T : IFoo, IBar<br /><br />How would you specify that the parameter implements <b>both</b> IFoo and IBar without that type constraint? You really couldn't. At best, you could write Foo to accept some larger interface type IFooBar that implements both IFoo and IBar:<br /><br />interface IFooBar : IFoo,IBar {}<br />void Foo(IFooBar afoo);<br /><br />But you have to plan for this ahead of time, and if you're interfacing with code that someone else wrote, you're SOL. You have to write a whole new adapter class to wrap the other class.<br /><br />The type constraints allowed you greater flexibility in composing code, and sharing constraints are almost exactly like the above type constraints in this regard.Sandro Magihttps://www.blogger.com/profile/05446177882449578817noreply@blogger.comtag:blogger.com,1999:blog-2744072865491516720.post-78116066211278175962012-02-03T18:37:12.790-05:002012-02-03T18:37:12.790-05:00Since I've never used ML, I would be curious t...Since I've never used ML, I would be curious to learn what is meant by "sharing specifications", what real-world problems it can solve, and how one would have to change the .NET type system to support it as well as ML supports it.Qwertiehttps://www.blogger.com/profile/04595705428290721343noreply@blogger.comtag:blogger.com,1999:blog-2744072865491516720.post-66154389216337273072009-12-02T12:39:31.752-05:002009-12-02T12:39:31.752-05:00Actually, Haskell does support type constructor po...Actually, Haskell does support type constructor polymorphism. They wouldn't be able to support monads otherwise.Sandro Magihttps://www.blogger.com/profile/05446177882449578817noreply@blogger.comtag:blogger.com,1999:blog-2744072865491516720.post-49199224124579409272009-12-02T11:28:34.759-05:002009-12-02T11:28:34.759-05:00You've kinda hit the tail on the head - you ca...You've kinda hit the tail on the head - you can't quite do this with .NET and have it be statically checked. <br /><br />And, the defining feature of SML/OCaml modules is sharing which you didn't include - and there's good experience that emulating these via abstraction isn't workable in practice (so really this is more like emulating Haskell than ML).<br /><br />Some of us would really like such things to be possible, but it really does require something fundamentally more powerful that .NET doesn't provide yet (nor Haskell in fact). SML has had this for 20 years, so it can't be long before it becomes possible... :-)Anonymoushttps://www.blogger.com/profile/02888491281001274822noreply@blogger.comtag:blogger.com,1999:blog-2744072865491516720.post-47421054829593680052009-12-02T11:14:25.016-05:002009-12-02T11:14:25.016-05:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/02888491281001274822noreply@blogger.comtag:blogger.com,1999:blog-2744072865491516720.post-28893782277058340672009-10-05T04:12:02.911-04:002009-10-05T04:12:02.911-04:00Hi, thank you for taking time to explain your enco...Hi, thank you for taking time to explain your encoding in the article! I find it very helpful. By the way, I am the poster of that StackOverflow question. I have turned the SO question into a wiki, which you are welcome to edit to link to your article. Thanks again.Anonymoushttps://www.blogger.com/profile/08313802559573057206noreply@blogger.com