Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bindings/haskell): support list and scan #2527

Merged
merged 3 commits into from
Jun 25, 2023
Merged

Conversation

silver-ymz
Copy link
Member

@silver-ymz silver-ymz commented Jun 25, 2023

Update:

  • export list and scan
  • add tests for copy, rename, list, scan
  • fix error of trailling \0 in leak_str
  • refactor OpMonad from custom type to type synonym in order to provide more available ways

I imitate DirStream in unix library to design Lister API. However, it doesn't seem very native and useful. I havn't came up with other solutions about it yet. Maybe we can improve it in the future.

@Xuanwo
Copy link
Member

Xuanwo commented Jun 25, 2023

I imitate DirStream in unix library to design Lister API. However, it doesn't seem very native and useful. I havn't came up with other solutions about it yet. Maybe we can improve it in the future.

How will haskell handle similiar works?

@silver-ymz
Copy link
Member Author

These are unix library API for DirStream.

openDirStream :: RawFilePath -> IO DirStream
readDirStream :: DirStream -> IO RawFilePath

It seems only to provide an iterator and next function.

These are the APIs I exported.

listOpRaw :: Operator -> String -> IO (Either OpenDALError Lister)
nextLister :: Lister -> IO (Either OpenDALError (Maybe String))
allLister :: Lister -> IO (Either OpenDALError [String])

list operation will return a Lister and we provide next and all operation for it.

The API I'm expecting is like ListT in pipe library. With it, users can use all standard library utilities like map, filter, etc. I may need to spend more time researching it.

@Xuanwo
Copy link
Member

Xuanwo commented Jun 25, 2023

we provide next and all operation for it.

Provide all on Lister is wrong since the Lister could be very large (more than 1M objects). It's by design that only has a next function.

Signed-off-by: silver-ymz <[email protected]>
Signed-off-by: silver-ymz <[email protected]>
@silver-ymz
Copy link
Member Author

I have removed all operation. Could you review again?

Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Xuanwo Xuanwo merged commit b78a82e into main Jun 25, 2023
@Xuanwo Xuanwo deleted the feat/haskell-list-scan branch June 25, 2023 07:48
@PsiACE PsiACE mentioned this pull request Jun 27, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants