From: Matthijs Kooijman Date: Fri, 30 Jan 2009 09:25:15 +0000 (+0100) Subject: Add a a new function "stateless". X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=648708abc1efd3a0bfb416bbbf1a8dff6362ecae;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add a a new function "stateless". This function converts a stateless circuit into a stateful one (with an empty state), so it can be simulated. --- diff --git a/Sim.hs b/Sim.hs index 3848508..5a8fe2d 100644 --- a/Sim.hs +++ b/Sim.hs @@ -1,4 +1,4 @@ -module Sim (simulate, SCircuit, Circuit, simulateIO) where +module Sim (simulate, SCircuit, Circuit, simulateIO, stateless) where import Data.Typeable simulate f input s = do @@ -50,4 +50,10 @@ printOutput (i, o, s) = do putStr "\nNew State: " putStr $ show s putStr "\n\n" + +-- Takes a stateless circuit and turns it into a stateful circuit (with an +-- empty state) so it can be used in simulation +stateless :: Circuit i o -> SCircuit i () o +stateless f = \i s -> (s, f i) + -- vim: set ts=8 sw=2 sts=2 expandtab: