Comments for The Comonad.Readerhttp://comonad.com/reader
types, (co)monads, substructural logicFri, 27 Feb 2015 23:23:58 -0800http://wordpress.org/?v=2.8.4hourly1Comment on Free Monoids in Haskell by Dan Doelhttp://comonad.com/reader/2015/free-monoids-in-haskell/comment-page-1/#comment-128416
Dan DoelFri, 27 Feb 2015 23:23:58 +0000http://comonad.com/reader/?p=977#comment-128416Imm: in a total language, this does not apply. Types are set-like, and the free monoid is a type of finite sequences. Types containing infinite sequences would not be free, because there is no means to map them correctly into other monoids, because you are not allowed to fold them.
dramforever: The point of this post was to show that the free monoid in Haskell is a type that contains infinite values. It is incorrect to use set-theoretic intuition and say that the free monoid only contains finite sequences (at least, if you care about things beyond a "fast and loose" level).
This is the same reason that data types contain infinite values in Haskell. They are still inductive definitions, but the induction is properly understood to be on domains, not sets. The domain structure induces the infinite values, despite induction 'normally' only giving you finite values in set theory. The same thing happens for free things.
Olaf: I think most Monoid instances are fine. The thing you usually have to be careful of is not being too lazy. For instance, if you write 'mappend _ _ = ()' for the unit monoid, it is wrong, because then 'mappend mempty undefined = ()', when it should be undefined. Most definitions can't get away without looking at the arguments, though, so they don't have this problem. (Monoid a, Monoid b) => Monoid (a,b) is another case where you'd have to be careful, though.
FM is a monad, and you have the relevant structure correct. It's also a MonadPlus that does the 'obvious' thing.Imm: in a total language, this does not apply. Types are set-like, and the free monoid is a type of finite sequences. Types containing infinite sequences would not be free, because there is no means to map them correctly into other monoids, because you are not allowed to fold them.

dramforever: The point of this post was to show that the free monoid in Haskell is a type that contains infinite values. It is incorrect to use set-theoretic intuition and say that the free monoid only contains finite sequences (at least, if you care about things beyond a “fast and loose” level).

This is the same reason that data types contain infinite values in Haskell. They are still inductive definitions, but the induction is properly understood to be on domains, not sets. The domain structure induces the infinite values, despite induction ‘normally’ only giving you finite values in set theory. The same thing happens for free things.

Olaf: I think most Monoid instances are fine. The thing you usually have to be careful of is not being too lazy. For instance, if you write ‘mappend _ _ = ()’ for the unit monoid, it is wrong, because then ‘mappend mempty undefined = ()’, when it should be undefined. Most definitions can’t get away without looking at the arguments, though, so they don’t have this problem. (Monoid a, Monoid b) => Monoid (a,b) is another case where you’d have to be careful, though.

FM is a monad, and you have the relevant structure correct. It’s also a MonadPlus that does the ‘obvious’ thing.

]]>Comment on Free Monoids in Haskell by Olafhttp://comonad.com/reader/2015/free-monoids-in-haskell/comment-page-1/#comment-128415
OlafThu, 26 Feb 2015 13:46:20 +0000http://comonad.com/reader/?p=977#comment-128415Is FM a monad? It seems yes: Just use return (=embed) and >>= of the continuation monad. Also, monoids should now be FM-algebras. What is the algebra structure map Monoid a => FM a -> a? The first thing that comes to mind is:
structure :: Monoid a => FM a -> a;
structure (FM f) = f id
At least struct.embed = id is true.Is FM a monad? It seems yes: Just use return (=embed) and >>= of the continuation monad. Also, monoids should now be FM-algebras. What is the algebra structure map Monoid a => FM a -> a? The first thing that comes to mind is:
structure :: Monoid a => FM a -> a;
structure (FM f) = f id
At least struct.embed = id is true.
]]>Comment on Free Monoids in Haskell by Olafhttp://comonad.com/reader/2015/free-monoids-in-haskell/comment-page-1/#comment-128414
OlafThu, 26 Feb 2015 12:51:25 +0000http://comonad.com/reader/?p=977#comment-128414Incidentally, (a -> m) -> m is the free algebra for the continuation monad. The monoid instance for (FM a) corresponds to what I think should be the MonadPlus instance of the continuation monad. By the way: Which of the existing Monoid instances are actually `proper' instances in the sense that the denotational semantics of mempty and make the semantic domain (including bottom and infinite values) a monoid?Incidentally, (a -> m) -> m is the free algebra for the continuation monad. The monoid instance for (FM a) corresponds to what I think should be the MonadPlus instance of the continuation monad. By the way: Which of the existing Monoid instances are actually `proper’ instances in the sense that the denotational semantics of mempty and make the semantic domain (including bottom and infinite values) a monoid?
]]>Comment on Free Monoids in Haskell by dramforeverhttp://comonad.com/reader/2015/free-monoids-in-haskell/comment-page-1/#comment-128413
dramforeverThu, 26 Feb 2015 09:26:46 +0000http://comonad.com/reader/?p=977#comment-128413P.S. I think that "the concept of free monoid must me generalized"P.S. I think that “the concept of free monoid must me generalized”
]]>Comment on Free Monoids in Haskell by dramforeverhttp://comonad.com/reader/2015/free-monoids-in-haskell/comment-page-1/#comment-128412
dramforeverThu, 26 Feb 2015 09:23:11 +0000http://comonad.com/reader/?p=977#comment-128412I believe it is incorrect. Values of the Foldable class can *also* be infinite. Consider:
toFreeMonoid (repeat 1)
There doesn't exist a free monoid set containing a string of infinite number of 1's, therefore either the concept of free monoid must me generalized, or the most fundamental operation of Foldable is not toFreeMonoid
(Correct me if I'm wrong.)I believe it is incorrect. Values of the Foldable class can *also* be infinite. Consider:

toFreeMonoid (repeat 1)

There doesn’t exist a free monoid set containing a string of infinite number of 1’s, therefore either the concept of free monoid must me generalized, or the most fundamental operation of Foldable is not toFreeMonoid

(Correct me if I’m wrong.)

]]>Comment on Free Monoids in Haskell by lmmhttp://comonad.com/reader/2015/free-monoids-in-haskell/comment-page-1/#comment-128407
lmmMon, 23 Feb 2015 10:40:27 +0000http://comonad.com/reader/?p=977#comment-128407So these differences are specific to lazy values and bottoms, right? In a language without either (e.g. Idris), does any of this apply?So these differences are specific to lazy values and bottoms, right? In a language without either (e.g. Idris), does any of this apply?
]]>Comment on Letter to a Young Haskell Enthusiast by heteroskedastichttp://comonad.com/reader/2014/letter-to-a-young-haskell-enthusiast/comment-page-1/#comment-128038
heteroskedasticFri, 23 Jan 2015 22:53:15 +0000http://comonad.com/reader/?p=933#comment-128038These are nice sentiments but it is strange that, at the end of the essay, the author links to a site, -- "ModelViewCulture" -- which embodies a dispensation (shrill, hostile, partisan, divisive, sanctimonious, etc, etc) that is the exact opposite of that which the essay itself recommends.These are nice sentiments but it is strange that, at the end of the essay, the author links to a site, — “ModelViewCulture” — which embodies a dispensation (shrill, hostile, partisan, divisive, sanctimonious, etc, etc) that is the exact opposite of that which the essay itself recommends.
]]>Comment on Mirrored Lenses by Haskellerhttp://comonad.com/reader/2012/mirrored-lenses/comment-page-1/#comment-128012
HaskellerTue, 20 Jan 2015 16:07:00 +0000http://comonad.com/reader/?p=600#comment-128012Lenses are extremely powerful but I hate the swearing comic character operators.
And who cares what an OOP programmer would expect? Aren't we more concerned with what a functional programmer would expect?Lenses are extremely powerful but I hate the swearing comic character operators.

And who cares what an OOP programmer would expect? Aren’t we more concerned with what a functional programmer would expect?

]]>Comment on Mirrored Lenses by How-to: lenses, fclabels, data-accessor – which library for structure access and mutation is better #development #fix #solution | IT Infohttp://comonad.com/reader/2012/mirrored-lenses/comment-page-1/#comment-128011
How-to: lenses, fclabels, data-accessor – which library for structure access and mutation is better #development #fix #solution | IT InfoTue, 20 Jan 2015 13:11:24 +0000http://comonad.com/reader/?p=600#comment-128011[...] recently written on how you can further generalize van Laarhoven lenses to get lens families that can change the types of fields, just by generalizing this signature [...][...] recently written on how you can further generalize van Laarhoven lenses to get lens families that can change the types of fields, just by generalizing this signature [...]
]]>Comment on Fast Circular Substitution by Andreas Reuleauxhttp://comonad.com/reader/2014/fast-circular-substitution/comment-page-1/#comment-127779
Andreas ReuleauxThu, 01 Jan 2015 23:02:15 +0000http://comonad.com/reader/?p=956#comment-127779Thanks a lot, that's the kind of Bound
example that I was waiting for: bigger than
the ones I have seen so far, but still digestible. I will take a closer look soon.Thanks a lot, that’s the kind of Bound
example that I was waiting for: bigger than
the ones I have seen so far, but still digestible. I will take a closer look soon.
]]>