If you want to play with a monadic fixpoint combinator in HBC, you can use module FixMonad where import UnsafeDirty(assign,deref,ref) fix :: Monad m => (a -> m a) -> m a fix f = do a <- f (deref r) assign r a `seq` return a where r = ref (undefined f) Here is a stupid example using the list monad: import FixMonad ones :: Monad m => m [Int] ones = fix (\x -> return (1:x)) main = print (ones :: [[Int]]) Disclaimer: No parts of this software have been tested on animals. /Magnus
- fixpoint combinator in monads Manuel Chakravarty
- Magnus Carlsson