[Haskell] do notation and type synonym

Tomasz Zielonka tomasz.zielonka at gmail.com
Sun Aug 7 14:42:19 EDT 2005


On Sun, Aug 07, 2005 at 08:26:07PM +0200, mt wrote:
> the first check5 is ok and return Nothing while the second check5' will raise 
> an "Exception: Non-exhaustive patterns" (which is what i've expected).
> 
> the sentence "there is nothing magic with do" with its reason are important 
> for me to understand monads and do notation, so maybe someone can rephrase 
> "there is nothing magic with do" and explain the exposed behavior?

The actual translation is a bit more complex to deal with (surprise!)
pattern-match failures, like in your code. See the third equation in the
"Translation" border on this page:
    http://www.haskell.org/onlinereport/exps.html#sect3.14
Still no magic.

> second one:
> is it possible to write something like
> type Point = (Float, Float)
> type Vector = (Float, Float)
> and still have type safety (i.e. not be able to mix Point and Vector) (and 
> still have (*,*) without constructor)?

I think it's not possible in current Haskell. If tuples were somehow
overloaded, as numbers are...

Best regards
Tomasz


More information about the Haskell mailing list