As a personal excercize in the process of learning Haskell , I am trying to transfer this F # snippet to Random Art .
I did not embed the full source code so as not to inflate the question, but is available as gist .
An important part of the program is this type Expr:
data Expr =
VariableX
| VariableY
| Constant
| Sum Expr Expr
| Product Expr Expr
| Mod Expr Expr
| Well Expr
| Tent Expr
| Sin Expr
| Level Expr Expr Expr
| Mix Expr Expr Expr
deriving Show
and two functions:
gen :: Int -> IO Expr random generates a tree structure, given the number of iterations
eval :: Expr -> IO (Point -> Rgb Double) scans the tree and completes the creation of the drawing function.
The higher the number, passed on gen, the higher the likelihood that will be created following exception: Ratio has zero denominator.
I am new to Haskell to solve the problem that I was trying to compile as described above:
ghc RandomArt.hs -prof -auto-all -caf-all
( ) info:
$ ./RandomArt +RTS -xc
*** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace:
GHC.Real.CAF
--> evaluated by: Main.eval.\,
called from Main.eval,
called from Main.tga.pxs',
called from Main.tga,
called from Main.save,
called from Main.main,
called from :Main.CAF:main
--> evaluated by: Main.eval.\.r,
called from Main.eval.\,
called from Main.eval,
called from Main.tga.pxs',
called from Main.tga,
called from Main.save,
called from Main.main,
called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace:
Main.tga,
called from Main.save,
called from Main.main,
called from GHC.Real.CAF
RandomArt: Ratio has zero denominator
, TGA, , excercize ( OCaml).
Expr GHCi, , .
Haskell loch, , ( cabal install , ).
, , :
.