since import { getEq as getArrayEq , lookup } from 'fp-ts/lib/Array' ; import { Eq , fromEquals } from 'fp-ts/lib/Eq' ; import { map , Option } from 'fp-ts/lib/Option' ; import { pipe } from 'fp-ts/lib/pipeable' ; category since export interface Stream < A > { readonly buffer : Array < A > ; readonly cursor : number ; } category since export const stream = ( buffer , cursor = 0 ) => ( { buffer , cursor } ) ; category since export const get = s => lookup ( s . cursor , s . buffer ) ; category since export const atEnd = s => s . cursor >= s . buffer . length ; category since export const getAndNext = s => pipe ( get ( s ) , map ( a => ( { value : a , next : { buffer : s . buffer , cursor : s . cursor + 1 } } ) ) ) ; category since export const getEq = E => { const EA = getArrayEq ( E ) ; return fromEquals ( ( x , y ) => x . cursor === y . cursor && EA . equals ( x . buffer , y . buffer ) ) ; } ;