Injecting stateful computations into pure Haskell code.
It is widely spread convention to simulate electronic circuits using infinite lazy lists. This works well for high level modeling, but when engineers ask to cosimulate it with Verilog or VHDL modules it goes somewhat off of pure functional programming. The main obstacle is that those modules have their own internal state. Is it possible to represent a result of several impure calculation as a pure list? The only way I can think of is the use of unsafePerformIO. Maybe State monad will help? And how?
Hello szefirov, Thursday, September 21, 2006, 2:04:38 PM, you wrote:
Is it possible to represent a result of several impure calculation as a pure list?
list = repeat (runST my_impure_calculation)
The only way I can think of is the use of unsafePerformIO.
runST is really a safe variant of unsafePerformIO :) - it limits operations allowed inside computation to ones what don't affect external world -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (2)
-
Bulat Ziganshin -
szefirov@ot.ru