I'm writing the Graphics (or SOEGraphics) module as used in Haskell SOE, based on your Plot example. <br /> I'm not sure what the best way to sequence drawing function is, in the absence of 'do' and the IO Monad. <br /> For example, where SOE has sierpinskiTri w x y size = if size <= minSize then fillTri w x y size else let size2 = size `div` 2 in do sierpinskiTri w x y size2 sierpinskiTri w x (y - size2) size2 sierpinskiTri w (x + size2) y size2 I have: sierpinskiTri w x y size = if size <= minSize then fillTri w x y size else let size2 = size / 2; in seq (sierpinskiTri w x y size2) (seq (sierpinskiTri w x (y - size2) size2) (sierpinskiTri w (x + size2) y size2) ); My solution works, but I don't think I understand Haskell or CAL deeply enough to be sure if it is a good solution. <br /> Tom
Using seq to explicitly order (i.e. sequence) stateful computations is a good idea. When using seq this way, we tend to use it in operator form (using the backquote syntax) to improve readability. For example:Â
sierpinskiTri w x y size =
   if size <= minSize then
       fillTri w x y size
   else
       let
           size2 = size / 2;
       in
           sierpinskiTri w x y size2
           `seq`          Â
           sierpinskiTri w x (y - size2) size2
           `seq`
           sierpinskiTri w (x + size2) y size2
           ;
Add a comment