On Jun 19, 2010, at 1:48 PM, Heinrich Apfelmus wrote:
In my code, mzero is indeed an identity for orElse [...]
The observation is any action can be brought into one of the forms
mzero
return a `mplus` return b `mplus` ...
which corresponds to the list type [a] .
Ok that makes sense
Sebastian Fischer wrote:
Heinrich Apfelmus wrote:
[...] you can implement your type as
newtype CMaybe a = CMaybe { forall b . (a - [b]) - [b] }
Yes. For me it was interesting to see how far we get by wrapping `Maybe`
in `Codensity`: we get more than `Maybe` but not as much as `[]`.
Sebastian Fischer wrote:
Consider the given Definitions of `CMaybe r a` with
`fromCMaybe`, `mzero`, `mplus`, `orElse`, and additionally:
toCMaybe :: Maybe a - CMaybe r a
toCMaybe a = CMaybe (\k - a = k)
getCMaybe :: CMaybe r a - (a - Maybe r) - Maybe r
getCMaybe (CMaybe
Edward Kmett wrote:
Sebastian Fischer wrote:
Heinrich Apfelmus wrote:
newtype CMaybe a = CMaybe (forall r. (a - Maybe r) - Maybe r)
Yes, with this type `orElse` has the same type as `mplus`, which is
very nice.
This type is the same as Codensity Maybe using category-extras
which is a 'bit
Heinrich Apfelmus wrote:
Sebastian Fischer wrote:
For example, the implementation of
`callCC` does not type check with your changed data type.
[snip]
As for the interaction: what should
((callCC ($ 0) mzero) `orElse` return 2) = return . (+3)
be? If the scope of callCC should
Sebastian Fischer wrote:
Edward Kmett wrote:
Sebastian Fischer wrote:
Heinrich Apfelmus wrote:
newtype CMaybe a = CMaybe (forall r. (a - Maybe r) - Maybe r)
Yes, with this type `orElse` has the same type as `mplus`, which is
very nice.
This type is the same as Codensity Maybe using
On Fri, Jun 18, 2010 at 12:44 PM, Heinrich Apfelmus
apfel...@quantentunnel.de wrote:
Sebastian Fischer wrote:
Edward Kmett wrote:
Sebastian Fischer wrote:
Heinrich Apfelmus wrote:
newtype CMaybe a = CMaybe (forall r. (a - Maybe r) - Maybe r)
Yes, with this type `orElse` has the same type as
David Menendez wrote:
Heinrich Apfelmus wrote:
Sebastian Fischer wrote:
I wonder whether for every monad `m` and `a :: Codensity m a`
getCodensity a f = getCodensity a return = f
Is this true? Why (not)?
It's not true.
a = Codensity $ \x - Just 42
f = return . (+1)
On Jun 18, 2010, at 8:55 PM, Heinrich Apfelmus wrote:
I wonder whether for every monad `m` and `a :: Codensity m a`
getCodensity a f = getCodensity a return = f
Is this true? Why (not)?
It's not true.
What a pity!
An example that is not generic in the base monad m , i.e. that
Heinrich Apfelmus wrote:
Sebastian Fischer wrote:
I still don't understand why it is impossible to provide `orElse`
with
the original type. I will think more about the reason you gave.
The reason is that you have chosen the wrong type for your
continuation monad; it should be
newtype
Sebastian Fischer wrote:
Heinrich Apfelmus wrote:
The reason is that you have chosen the wrong type for your
continuation monad; it should be
newtype CMaybe a = CMaybe (forall r. (a - Maybe r) - Maybe r)
Yes, with this type `orElse` has the same type as `mplus`, which is very
nice.
On Wed, Jun 16, 2010 at 9:11 AM, Sebastian Fischer
s...@informatik.uni-kiel.de wrote:
Heinrich Apfelmus wrote:
Sebastian Fischer wrote:
I still don't understand why it is impossible to provide `orElse` with
the original type. I will think more about the reason you gave.
The reason is
Sebastian Fischer wrote:
Holger Siegel wrote:
orElse :: CMaybe a a - CMaybe a a - CMaybe r a
CMaybe ca `orElse` CMaybe cb = CMaybe (\k - (ca return `mplus` cb
return) = k)
I still don't understand why it is impossible to provide `orElse` with
the original type. I will think more about
13 matches
Mail list logo