2020-09-19 15:22:54 +03:00
|
|
|
module Data.String.Iterator
|
|
|
|
|
2020-09-19 23:46:46 +03:00
|
|
|
import public Data.List.Lazy
|
|
|
|
|
2020-09-19 22:54:34 +03:00
|
|
|
%default total
|
2020-09-19 15:22:54 +03:00
|
|
|
|
2020-09-19 22:54:34 +03:00
|
|
|
export
|
|
|
|
data StringIterator : Type where [external]
|
2020-09-19 15:22:54 +03:00
|
|
|
|
2020-09-19 22:54:34 +03:00
|
|
|
%foreign
|
|
|
|
"scheme:blodwen-string-iterator-new"
|
2020-09-19 15:22:54 +03:00
|
|
|
export
|
|
|
|
fromString : String -> StringIterator
|
|
|
|
|
2020-09-19 22:54:34 +03:00
|
|
|
%foreign
|
|
|
|
"scheme:blodwen-string-iterator-next"
|
2020-09-19 15:22:54 +03:00
|
|
|
export
|
|
|
|
uncons : StringIterator -> Maybe (Char, StringIterator)
|
|
|
|
|
2020-09-19 23:46:46 +03:00
|
|
|
export
|
|
|
|
unpack : String -> LazyList Char
|
|
|
|
unpack = unsafeUnfoldr uncons . fromString
|