fs2 icon indicating copy to clipboard operation
fs2 copied to clipboard

Add support for Scala Native

Open sluramod opened this issue 4 years ago • 2 comments

Cats (https://github.com/typelevel/cats) recently added support (https://github.com/typelevel/cats/issues/1549) for cross-compiling to scala native.

Scala Native support in fs2 would be be very helpful.

sluramod avatar Mar 08 '21 06:03 sluramod

This would of course depend on cats-effect support for Scala Native, as well. https://github.com/typelevel/cats-effect/issues/1302

diesalbla avatar Mar 08 '21 10:03 diesalbla

I started some preliminary investigation in https://github.com/armanbilge/fs2/commit/20a1dbb0159105c9e37106aa1e1b52bd74102863 based on https://github.com/typelevel/cats-effect/pull/3057.

Crossing fs2-core is straightforward.

  • porting java.util.zip.InflaterOutputStream to Scala Native would unblock compression

fs2-io is a lot more work. I focused only on the fs2.io.file package for now.

  • java.nio.file.Path#register is missing
  • so is java.util.stream.Stream#forEach

Without those, cross-compiling fs2.io.file will require complex splitting/platforming to remove Watcher (which is otherwise very nearly supported). We should port the missing APIs to Scala Native instead.

Furthermore, when running the fs2-io suite on Native I encountered the following failures.

X fs2.io.file.FilesSuite.permissions - innappropriate access should raise AccessDeniedException
X fs2.io.file.FilesSuite.delete - should fail on a non empty directory
X fs2.io.file.PathSuite.Monoid[Path]: monoid.right identity

The underlying bugs should all be fixed in Scala Native.

PRs:

  • https://github.com/scala-native/scala-native/pull/2749
  • https://github.com/scala-native/scala-native/pull/2748
  • https://github.com/scala-native/scala-native/pull/2747
  • https://github.com/scala-native/scala-native/pull/2745
  • https://github.com/scala-native/scala-native/pull/2753

Issues:

  • https://github.com/scala-native/scala-native/issues/2750
  • https://github.com/scala-native/scala-native/issues/2751

armanbilge avatar Jul 23 '22 04:07 armanbilge

PR is up at https://github.com/typelevel/fs2/pull/2975.

armanbilge avatar Sep 10 '22 23:09 armanbilge