edwinb/Idris-dev — pull request #153 by LeifW (2013-01-14 09:44:18+00:00)
Title: Added cast instances both directions between Maybe and Monoids.

Casting `m: Maybe a` *to* a monoid would be equivalent to `fromMaybe neutral m`.
Scalaz has a `.orZero` / `~` method that's handy for just convering a Maybe a to a "" or 0 or whatever - the Monoid identity is a common "default" value on "no value".
https://github.com/scalaz/scalaz/blob/master/core/src/main/scala/scalaz/OptionW.scala#L82

The other direction should be an inverse pretty much. We have a fair amount of that going on in our (non-Idris) code at work - turning false, "", etc into Nothing (I notice there's no Monoid instance for Boolean as I write this - could add one to this PR. It's just xor / false). `toMaybe b j` might be equivalent to `fmap (const j) (cast b)`.