I notice that a lot of things get composed:
- Actions in a Monad
- Types (sum types)
So I was wondering just how crazy a generic (as in works for all of the above) definition of a compose operator/function would be. I don't necessarily care if haskell can do it (though it would be cool to see how close we can get, my limited understanding is that lens is basically trying to do this.)submitted by satsujinka
[link] [29 comments]
You sometimes hear people claim that there is no perfectly efficient machine, that every machine wastes some of its input energy in noise or friction.
However, there is a counterexample. An electric space heater is perfectly efficient. Its purpose is to heat the space around it, and 100% of the input energy is applied to this purpose. Even the electrical energy lost to resistance in the cord you use to plug it into the wall is converted to heat.
Wait, you say, the space heater does waste some of its energy. The coils heat up, and they emit not only heat, but also light, which is useless, being a dull orange color. Ah! But what happens when that light hits the wall? Most of it is absorbed, and heats up the wall. Some is reflected, and heats up a different wall instead.
Similarly, a small fraction of the energy is wasted in making a quiet humming noise—until the sound waves are absorbed by the objects in the room, heating them slightly.
Now it's true that some heat is lost when it's radiated from the outside of the walls and ceiling. But some is also lost whenever you open a window or a door, and you can't blame the space heater for your lousy insulation. It heated the room as much as possible under the circumstances.
So remember this when you hear someone complain that incandescent light bulbs are wasteful of energy. They're only wasteful in warm weather. In cold weather, they're free.
Thought I would give generalizing Data.Maybe a shot using GHC.Generics after this conversation https://twitter.com/HaskellTips/status/432337300920352769
Thoughts?submitted by jfischoff
[link] [52 comments]