--- /dev/null
+importJava "java.util.Iterator" where
+ data T a
+
+ hasNext :: T a -> <Proc> Boolean
+ next :: T a -> <Proc> a
+ remove :: T a -> <Proc> ()
+
+@inline
+iter :: (a -> <e> b) -> T a -> <Proc,e> ()
+iter f it = loop ()
+ where
+ loop _ =
+ if hasNext it
+ then do
+ f (next it)
+ loop ()
+ else ()
+
+@inline
+iterB :: (a -> <e> Boolean) -> T a -> <Proc,e> Boolean
+iterB f it = loop ()
+ where
+ loop _ =
+ if hasNext it
+ then if f (next it)
+ then loop ()
+ else False
+ else True
+
+@inline
+mapFirst :: (a -> <e> Maybe b) -> T a -> <Proc,e> Maybe b
+mapFirst f it = loop ()
+ where
+ loop _ =
+ if hasNext it
+ then match f (next it) with
+ Nothing -> loop ()
+ r -> r
+ else Nothing
+
+@inline
+fold :: (a -> b -> <e> a) -> a -> T b -> <Proc,e> a
+fold f init it = loop init
+ where
+ loop cur =
+ if hasNext it
+ then loop (f cur (next it))
+ else cur
+
+importJava "java.lang.Iterable" where
+ data Iterable a
+
+ iterator :: Iterable a -> <Proc> T a