Skip to content

Instantly share code, notes, and snippets.

@izgzhen
Created June 3, 2017 05:29
Show Gist options
  • Save izgzhen/ea3bdbb571308dcb32295c7e215b39e1 to your computer and use it in GitHub Desktop.
Save izgzhen/ea3bdbb571308dcb32295c7e215b39e1 to your computer and use it in GitHub Desktop.
module Main where
import DDF.PE
import DDF.Double
import DDF.Show
import DDF.Meta.Interpreter
import qualified Prelude as M
import Data.IORef
import System.IO.Unsafe
import Control.Monad
count :: IORef M.Int
count = unsafePerformIO (newIORef (0 :: M.Int))
tick :: M.Bool
-- tick = unsafePerformIO (modifyIORef count (+1) >> M.return M.True)
tick = unsafePerformIO (print "hello" >> M.return M.True)
countVal :: M.Int
countVal = unsafePerformIO (readIORef count)
flush :: ()
flush = unsafePerformIO (writeIORef count (0 :: M.Int))
main :: M.IO ()
main = do
print $ runShow x [] 1
-- print $ runShow x' [] 1
print $ countVal
M.return ()
-- Tests
t1 :: Double r => r h M.Double
t1 | tick = app2 doublePlus (double 1.0) (double 2.0)
x, x' :: Double r => r () (M.Double -> M.Double)
x = hoas (\_ -> t1)
x' = pe x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment