[Haskell-cafe] Deconstruction

haskell at kudling.de haskell at kudling.de
Sat Dec 26 11:53:21 EST 2009


Hi all, 


thanks for the insight.

> But you can deconstruct the enclosed value temporarily:
>
> getSomething :: Bar -> Double
> getSomething b =
>      case b of
>          Bar a -> doSomething a



Somehow i fail to apply this.


If you look at
http://chlor.svn.sourceforge.net/viewvc/chlor/trunk/haskell/Chlor/Object.hs?revision=603&view=markup


in line 26 i used this for function "adjustToBox", but i still get:



Chlor/Object.hs:33:36:
    Couldn't match expected type `ObjectWrapper'
           against inferred type `a'
      `a' is a rigid type variable bound by
          the constructor `ObjectWrapper' at Chlor/Object.hs:33:12
    In the expression: adjustToBox object
    In a case alternative: ObjectWrapper object -> adjustToBox object
    In the expression:
        case wrapper of { ObjectWrapper object -> adjustToBox object }


:(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091226/7c00540a/attachment.html


More information about the Haskell-Cafe mailing list