cmonad-0.1.0.0: examples/Inf.hs
{-# OPTIONS_GHC -fglasgow-exts #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Inf where
import Prelude()
import Language.CMonad
inf :: forall m r . (MonadRef m r) =>
m Double
inf = runE $ do
s <- auto 0
i <- auto 0
for (i =: 1, (i :: E m Double) <= 1e3, i+=1) $ do
s += 1/i
retrn s
main = do
x <- inf
putStrLn $ "Almost infinity is " ++ show x