Mercurial > repo
view paste/paste.29654 @ 12154:d6aa7ae53124 draft
<oerjan> revert
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Mon, 18 Nov 2019 02:45:48 +0000 |
parents | 88ac0a2c9959 |
children |
line wrap: on
line source
2012-07-06.txt:22:39:36: <zzo38> I think this can make a MonadPlus whenever w is a comonad: newtype CodensityAsk w x = CodensityAsk { runCodensityAsk :: forall z. w z -> (x -> z) -> z }; (and that it seems to always make a monad) 2012-07-08.txt:04:36:14: <zzo38> Do you figure out about CodensityAsk, CodensityAskT, DensityAsk, DensityAskT? 2012-07-08.txt:04:37:08: <zzo38> (The way I have it, (CodensityAsk w) make MonadPlus if w is Comonad; hopefully it is correct although I am not completely sure) 2012-07-08.txt:05:04:03: <zzo38> I did not post the CodensityAskT on here so now I will: newtype CodensityAskT w m x = CodensityAskT { runCodensityAskT :: forall z. w (m z) -> (x -> m z) -> m z }; 2012-07-08.txt:05:07:42: <zzo38> You have said before that (Yoneda Endo) makes a Maybe monad, although you cannot get the instances for free. (CodensityAsk Identity) would be the same kind of things, isn't it? You will get Monad and MonadPlus instance for free. 2012-07-08.txt:06:18:42: <zzo38> (There is also CodensityAsk which is the same except without the "m"; the reason it is separate is because w could be anything not necessarily even a endofunctor or contrafunctor) 2012-07-08.txt:11:20:30: <zzo38> Now I made up this: catchCodensityAskT :: (Functor w, Monad m) => w (CodensityAskT w m x) -> CodensityAskT w m x -> CodensityAskT w m x; 2012-07-08.txt:11:35:31: <zzo38> I made up the catch for CodensityAsk; can it be made finally as well? 2012-07-08.txt:11:55:26: <zzo38> (CodensityAsk Predicate) seems to be the exhaustively searchable set monad as in "infinite-search" package. The type can be proven the same by Yoneda and the monad seem to work same way too 2012-07-08.txt:17:29:58: <zzo38> (CodensityAsk $ \(X q) k -> k 'a' ++ k 'b' ++ maybe [] return q) :: CodensityAsk (X [] Maybe) Char 2012-07-09.txt:04:47:23: <zzo38> I figured out how you can make a free monad using a F-algebra: toFree (CodensityAsk f) = f (Algebra Free) Pure; mkFree x = CodensityAsk (\(Algebra q) k -> q (fmap k x)); 2012-07-09.txt:06:04:15: <zzo38> I figured out how you can make a free monad using a F-algebra: toFree (CodensityAsk f) = f (Algebra Free) Pure; mkFree x = CodensityAsk (\(Algebra q) k -> q (fmap k x)); 2012-07-13.txt:23:31:34: <zzo38> You get CodensityAsk ((->) x) to be like Either x including a MonadPlus instance if x is a monoid 2012-07-15.txt:01:15:17: <zzo38> Do you like CodensityAsk (and CodensityAskT)? I have figured out many things about it. 2012-07-15.txt:01:20:21: <zzo38> (CodensityAsk (Store s)) is also MonadPlus. 2012-07-15.txt:09:55:17: <zzo38> type Sto s = CodensityAsk (Store s); getSto = CodensityAsk (\(StoreT _ s) r -> r s); setSto x = CodensityAsk (\(StoreT (Identity f) _) _ -> f x); modSto x = CodensityAsk (\(StoreT (Identity f) s) _ -> f (x s)); runSto s (CodensityAsk f) = f (store Left s) Right; 2012-07-16.txt:04:52:48: <zzo38> In my program it is called (CodensityAsk (Store x)) 2012-07-16.txt:20:52:19: <zzo38> Is it correct? Codensity Endo = [] CodensityAsk Endo = Writer (Sum Natural) Density Endo = Traced (Product Natural) 2012-07-16.txt:21:34:46: <zzo38> edwardk: Is it this? CodensityAsk Endo = Writer (Sum Natural) Density Endo = Traced (Product Natural) 2012-07-16.txt:21:45:32: <zzo38> By F-algebras I would suppose (CodensityAsk Endo) would be same like (Free Identity) 2012-08-14.txt:06:44:36: <zzo38> Perhaps you can even make up a kind of multi-continuation by CodensityAsk with some GADT. 2012-08-24.txt:02:48:53: <zzo38> That newtype Search f a = Search { optimum :: f a -> a } I have also called Algebra (as a F-algebra is). I also think that if f is Predicate you get the "infinite search" monad that someone else described, and I think also (CodensityAsk Predicate) is also the same, too! 2012-08-24.txt:02:54:33: <zzo38> newtype CodensityAsk f x = CodensityAsk { runCodensityAsk :: forall z. f z -> (x -> z) -> z }; 2012-08-24.txt:02:54:57: <zzo38> It is always a Monad. If f is Comonad then (CodensityAsk) is also a MonadPlus. 2012-08-24.txt:02:55:09: <zzo38> It is always a Monad. If f is Comonad then (CodensityAsk f) is also a MonadPlus. 2012-08-24.txt:02:55:54: <zzo38> There is also CodensityAskT which every "z" in that definition would be "m z" instead 2012-08-24.txt:05:18:51: <zzo38> I said I proved that (CodensityAsk Predicate) is actually the same as the infinite search monad; actually, I have only proven that the type is equivalent, not that the monad is equivalent. However, it seems to be equivalent monad from testing it. 2012-10-08.txt:17:09:40: <zzo38> I think you can make a writer monad with Codensity and it can also be done with CodensityAsk. 2012-10-08.txt:17:18:50: <zzo38> For example: newtype X y z = X { runX :: y -> z -> z }; type Writer x = CodensityAsk (X x); write x = CodensityAsk (\(X a) f -> a x $ f ()); runWriter (CodensityAsk f) = f (X $ (b, c) -> (a : b, c)) ((,) []); 2012-10-10.txt:05:08:51: <shachaf> zzo38: Where did your CodensityAsk type come from? 2012-10-10.txt:05:17:06: <shachaf> zzo38: Can you express CodensityAsk as a CodensityAsk type? 2012-10-10.txt:05:19:05: <zzo38> shachaf: I suppose you can use (CodensityAsk (IdentityT f)) but I don't know if that is what you meant 2012-10-10.txt:05:22:44: <shachaf> zzo38: What's CodensityAsk (Cont r)? 2012-10-10.txt:05:24:29: <zzo38> However, notice that you don't need to use a functor there, it can be anything, such as (CodensityAsk Predicate) to make up the infinite search monad. 2012-10-10.txt:05:25:01: <shachaf> zzo38: CodensityAsk is "pretty damn awesome", confirms another channel. 2012-10-10.txt:06:10:56: <shachaf> @ask zzo38 Is this the CodensityAsk Monad (>>=)? m >>= f = CA $ \q k -> runCA m q (\x -> runCA (f x) q k) 2012-10-10.txt:19:42:26: <oerjan> `pastelogs zzo38 codensityask 2012-10-10.txt:19:42:34: <oerjan> `pastelogs zzo38.*codensityask