Is there an indexed list in Haskell and is it good or bad?

Viewed 183

I am a new comer to the Haskell world and I am wondering if there is something like this:

data IndexedList a = IList Int [a]

findIndex::(Int->Int)->IndexedList a->(a,IndexedList a)
findIndex f (IList x l) = (l!!(f x), IList (f x) l)

next::IndexedList a->(a,IndexedList a)
next x = findIndex (+1) x

I've noticed that this kind of list is not purely functional but kind of useful for some applications. Should it be considered harmful?

Thanks,

Bob

2 Answers
Related