Idris2/libs/contrib/Data/String/Iterator.idr
2020-09-19 22:48:45 +02:00

23 lines
417 B
Idris

module Data.String.Iterator
import public Data.List.Lazy
%default total
export
data StringIterator : Type where [external]
%foreign
"scheme:blodwen-string-iterator-new"
export
fromString : String -> StringIterator
%foreign
"scheme:blodwen-string-iterator-next"
export
uncons : StringIterator -> Maybe (Char, StringIterator)
export
unpack : String -> LazyList Char
unpack = unsafeUnfoldr uncons . fromString