r/purescript • u/robertmassaioli • Jan 02 '17
RFC: purescript-infinite-list
This is the first library that I am submitting to Pursuit. I wanted a library that gave me infinite lists with a few properties:
- It would be memory efficient
- You would only pay the cost of the elements in your infinite list when you requested them.
- Functions like 'head' and 'tail' would not require the use of the Maybe type to be complete (non-partial) functions.
This is my best attempt: https://pursuit.purescript.org/packages/purescript-infinite-list/0.2.1
The thing that I am least pleased about is that Purescript does not support "Tail Call Optimization modulo cons" and, as a result, the 'take' and 'takeWhile' functions needed to be reimplemented using the FFI to prevent too many nested function calls. (See: https://github.com/robertmassaioli/purescript-infinite-list/blob/master/src/Data/InfiniteList.js) It would be great if the purescript community reconsidered that decision.
Please have a look at the library and give feedback if you have any.
View all comments
Show parent comment
1
u/robertmassaioli Jan 02 '17
Awesome! I was hoping that there would be some way to achieve this without resorting to the FFI. I'll try and understand this code fully and then use it to implement tail and tailWith.
You rock!