
Please see below. On Oct 10, 2013, at 10:09 PM, Edward Kmett wrote:
Wait, that sounds like it induces bad semantics.
Can't we use that as yet another way to attack the sanctity of Set?
class Ord a => Foo a where badInsert :: a -> Set a -> Set a
instance Foo Int where badInsert = insert
newtype Bar = Bar Int deriving (Eq,Foo)
instance Ord Bar where compare (Bar x) (Bar y) = compare y x
Now you can badInsert into a Set.
If that is still in play then even with all the roles machinery then GND doesn't pass the restrictions of "SafeHaskell". =(
Hrm. Yes. I'm out of fresh ideas at the moment. Maybe some will arrive with sleep. Richard
From marlowsd at gmail.com Tue Oct 1 12:39:58 2013 From: marlowsd at gmail.com (Simon Marlow) Date: Tue, 01 Oct 2013 13:39:58 +0100 Subject: Desugaring do-notation to Applicative Message-ID: <524AC29E.9010203@gmail.com> X-List-Received-Date: Sat, 12 Oct 2013 07:42:45 -0000 X-List-Received-Date: Sat, 12 Oct 2013 07:42:45 -0000
Following a couple of discussions at ICFP I've put together a proposal for desugaring do-notation to Applicative: http://ghc.haskell.org/trac/ghc/wiki/ApplicativeDo I plan to implement this following the addition of Applicative as a superclass of Monad, which is due to take place shortly after the 7.8 branch is cut. Please discuss here, and I'll update the wiki page as necessary. Cheers, Simon
From simonpj at microsoft.com Tue Oct 1 13:49:40 2013 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue, 1 Oct 2013 13:49:40 +0000 Subject: Desugaring do-notation to Applicative In-Reply-To: <524AC29E.9010203@gmail.com> References: <524AC29E.9010203@gmail.com> Message-ID: <59543203684B2244980D7E4057D5FBC1485F7075@DB3EX14MBXC306.europe.corp.microsoft.com> X-List-Received-Date: Sat, 12 Oct 2013 07:42:45 -0000 X-List-Received-Date: Sat, 12 Oct 2013 07:42:45 -0000
What happens when there are some monad things that precede the applicative bit: do { x <- e1 ; y <- e2[x] ; z <- e3[x] ; h[y] ... } does this convert to do { x <- e1 ; (y,z) <- (,) <$> e1 <*> e2 ; h[y] ... I assume so, but it would be good to say. Also worth noting that join can be used to eliminate the tuple in arbitrary contexts, not only ones that end in return. Eg in the above example we can desugar to e1 >>= \x -> join (\y z -> do { h[y]; ... }) e2 e3 I think. Again worth documenting if so. I don't know whether the tuple-version or join-version would be more optimisation friendly. Simon | -----Original Message----- | From: Glasgow-haskell-users [mailto:glasgow-haskell-users- | bounces at haskell.org] On Behalf Of Simon Marlow | Sent: 01 October 2013 13:40 | To: glasgow-haskell-users | Subject: Desugaring do-notation to Applicative | | Following a couple of discussions at ICFP I've put together a proposal | for desugaring do-notation to Applicative: | | http://ghc.haskell.org/trac/ghc/wiki/ApplicativeDo | | I plan to implement this following the addition of Applicative as a | superclass of Monad, which is due to take place shortly after the 7.8 | branch is cut. | | Please discuss here, and I'll update the wiki page as necessary. | | Cheers, | Simon | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users at haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
From eir at cis.upenn.edu Tue Oct 1 20:39:16 2013 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Tue, 1 Oct 2013 16:39:16 -0400 Subject: Desugaring do-notation to Applicative In-Reply-To: <59543203684B2244980D7E4057D5FBC1485F7075@DB3EX14MBXC306.europe.corp.microsoft.com> References: <524AC29E.9010203@gmail.com> <59543203684B2244980D7E4057D5FBC1485F7075@DB3EX14MBXC306.europe.corp.microsoft.com> Message-ID: <8A0E5BAE-A047-4F2E-A171-3EE8972051DB@cis.upenn.edu> X-List-Received-Date: Sat, 12 Oct 2013 07:42:46 -0000 X-List-Received-Date: Sat, 12 Oct 2013 07:42:46 -0000
The soundness of this desugaring depends on the Applicatives and Monads following some of the laws. I think that's OK, personally, but this assumption should be made loudly somewhere, and the feature should be opt-in. As far as I know, GHC currently makes no assumptions about lawful class instances, and it might cause very strange failures if this suddenly were to change without opting in. Richard On Oct 1, 2013, at 9:49 AM, Simon Peyton-Jones wrote:
What happens when there are some monad things that precede the applicative bit:
do { x <- e1 ; y <- e2[x] ; z <- e3[x] ; h[y] ... }
does this convert to
do { x <- e1 ; (y,z) <- (,) <$> e1 <*> e2 ; h[y] ...
I assume so, but it would be good to say.
Also worth noting that join can be used to eliminate the tuple in arbitrary contexts, not only ones that end in return. Eg in the above example we can desugar to
e1 >>= \x -> join (\y z -> do { h[y]; ... }) e2 e3
I think. Again worth documenting if so.
I don't know whether the tuple-version or join-version would be more optimisation friendly.
Simon
| -----Original Message----- | From: Glasgow-haskell-users [mailto:glasgow-haskell-users- | bounces at haskell.org] On Behalf Of Simon Marlow | Sent: 01 October 2013 13:40 | To: glasgow-haskell-users | Subject: Desugaring do-notation to Applicative | | Following a couple of discussions at ICFP I've put together a proposal | for desugaring do-notation to Applicative: | | http://ghc.haskell.org/trac/ghc/wiki/ApplicativeDo | | I plan to implement this following the addition of Applicative as a | superclass of Monad, which is due to take place shortly after the 7.8 | branch is cut. | | Please discuss here, and I'll update the wiki page as necessary. | | Cheers, | Simon | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users at haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users at haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
From dag.odenhall at gmail.com Tue Oct 1 20:56:55 2013 From: dag.odenhall at gmail.com (Dag Odenhall) Date: Tue, 1 Oct 2013 22:56:55 +0200 Subject: Desugaring do-notation to Applicative In-Reply-To: <8A0E5BAE-A047-4F2E-A171-3EE8972051DB@cis.upenn.edu> References: <524AC29E.9010203@gmail.com> <59543203684B2244980D7E4057D5FBC1485F7075@DB3EX14MBXC306.europe.corp.microsoft.com> <8A0E5BAE-A047-4F2E-A171-3EE8972051DB@cis.upenn.edu> Message-ID:
X-List-Received-Date: Sat, 12 Oct 2013 07:42:46 -0000 X-List-Received-Date: Sat, 12 Oct 2013 07:42:46 -0000
At least Control.Category has RULES that exploit the category laws for optimization. Whether this counts as *GHC* making assumptions, I don't know. :-) On Tue, Oct 1, 2013 at 10:39 PM, Richard Eisenberg <eir at cis.upenn.edu>wrote:
The soundness of this desugaring depends on the Applicatives and Monads following some of the laws. I think that's OK, personally, but this assumption should be made loudly somewhere, and the feature should be opt-in. As far as I know, GHC currently makes no assumptions about lawful class instances, and it might cause very strange failures if this suddenly were to change without opting in.
Richard
On Oct 1, 2013, at 9:49 AM, Simon Peyton-Jones wrote:
What happens when there are some monad things that precede the applicative bit:
do { x <- e1 ; y <- e2[x] ; z <- e3[x] ; h[y] ... }
does this convert to
do { x <- e1 ; (y,z) <- (,) <$> e1 <*> e2 ; h[y] ...
I assume so, but it would be good to say.
Also worth noting that join can be used to eliminate the tuple in arbitrary contexts, not only ones that end in return. Eg in the above example we can desugar to
e1 >>= \x -> join (\y z -> do { h[y]; ... }) e2 e3
I think. Again worth documenting if so.
I don't know whether the tuple-version or join-version would be more optimisation friendly.
Simon
| -----Original Message----- | From: Glasgow-haskell-users [mailto:glasgow-haskell-users- | bounces at haskell.org] On Behalf Of Simon Marlow | Sent: 01 October 2013 13:40 | To: glasgow-haskell-users | Subject: Desugaring do-notation to Applicative | | Following a couple of discussions at ICFP I've put together a proposal | for desugaring do-notation to Applicative: | | http://ghc.haskell.org/trac/ghc/wiki/ApplicativeDo | | I plan to implement this following the addition of Applicative as a | superclass of Monad, which is due to take place shortly after the 7.8 | branch is cut. | | Please discuss here, and I'll update the wiki page as necessary. | | Cheers, | Simon | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users at haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users at haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users at haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users