On 6-12-2011 21:21, Vag Vagoff wrote:
..
As Dee Mon (http://thedeemon.com) has noticed that subgraph with type
signature always regarded as function.

For example, in

test1 n = a + a where a = somefunc 0 + 1

'a' is subgraph and computed only once but in

test2 n = a + a where
a :: Int
a = somefunc 0 + 1

'a' regarded as function and computes twice (i.e. no memoization occurs).

Why is and how to coincide this compiler behavior with the language spec?

The compiler only supports type specifications for functions and dynamics. The languages spec calls these FunctionType and DynamicType.

Since 'a' is a function, somefunc will be recomputed each time a is called. If you want to prevent recomputation you could define both a function and a variable:

test2 n = a + a where
  a = fa

  fa :: Int
  fa = somefunc 0 + 1

Kind regards,

John van Groningen
_______________________________________________
clean-list mailing list
[email protected]
http://mailman.science.ru.nl/mailman/listinfo/clean-list

Reply via email to