diff --git a/doctests.hs b/doctests.hs
--- a/doctests.hs
+++ b/doctests.hs
@@ -8,17 +8,20 @@
 import Test.DocTest
 import Test.HUnit
 
+main :: IO ()
 main = do
     doctest
       [ "-isrc"
       , "-XOverloadedStrings"
       , "src/System/Posix/FilePath"
       ]
-    runTestTT unitTests
+    _ <- runTestTT unitTests
+    pure ()
 
 unitTests :: Test
 unitTests = test
     [ TestCase $ do
-        r <- (==) <$> allDirectoryContents "." <*> allDirectoryContents' "."
-        assertBool "allDirectoryContents == allDirectoryContents'" r
+        a <- allDirectoryContents "."
+        b <- allDirectoryContents' "."
+        assertEqual "allDirectoryContents == allDirectoryContents'" a b
     ]
diff --git a/posix-paths.cabal b/posix-paths.cabal
--- a/posix-paths.cabal
+++ b/posix-paths.cabal
@@ -1,5 +1,5 @@
 name:  posix-paths
-version:  0.3.0.0
+version:  0.3.0.1
 license: BSD3
 license-file: LICENSE
 maintainer: jwlato@gmail.com
@@ -16,7 +16,7 @@
                     benchmarks/*.hs
 extra-tmp-files:
 build-type: Simple
-Cabal-Version: >= 1.14
+Cabal-Version: 1.14
 
 Library
     hs-source-dirs:     src
@@ -27,7 +27,10 @@
                         System.Posix.FilePath
     build-depends:      base >= 4.2 && < 5,
                         bytestring >= 0.9.2.0,
-                        unix >= 2.5.1.0,
+                        -- System.Posix.Directory.Internals (exposing the
+                        -- DirStream constructor and CDir/CDirent types) was
+                        -- introduced in unix-2.8.0.0 (August 2022).
+                        unix >= 2.8.0.0,
                         unliftio >= 0.2
 
 test-suite doctests
@@ -58,8 +61,8 @@
       filepath   >= 1.2,
       process    >= 1.0,
       criterion  >= 0.6
-  ghc-options: -Wall -O2
+  ghc-options: -Wall
 
 source-repository head
   type:                git
-  location:            git://github.com/JohnLato/posix-paths.git
+  location:            https://github.com/JohnLato/posix-paths.git
diff --git a/src/System/Posix/Directory/Traversals.hs b/src/System/Posix/Directory/Traversals.hs
--- a/src/System/Posix/Directory/Traversals.hs
+++ b/src/System/Posix/Directory/Traversals.hs
@@ -37,13 +37,13 @@
 import UnliftIO.Exception
 
 import System.IO.Unsafe
-import Unsafe.Coerce (unsafeCoerce)
 import Foreign.C.Error
 import Foreign.C.String
 import Foreign.C.Types
 import Foreign.Marshal.Alloc (alloca,allocaBytes)
 import Foreign.Ptr
 import Foreign.Storable
+import System.Posix.Directory.Internals (DirStream(DirStream),CDir ,CDirent)
 
 ----------------------------------------------------------
 
@@ -118,19 +118,15 @@
     modifyIOError f (runInIO action)
 
 ----------------------------------------------------------
--- dodgy stuff
 
-type CDir = ()
-type CDirent = ()
 
--- Posix doesn't export DirStream, so to re-use that type we need to use
--- unsafeCoerce.  It's just a newtype, so this is a legitimate usage.
--- ugly trick.
+-- unpacks the DirStream
 unpackDirStream :: DirStream -> Ptr CDir
-unpackDirStream = unsafeCoerce
+unpackDirStream (DirStream p) = p
 
+
 packDirStream :: Ptr CDir -> DirStream
-packDirStream = unsafeCoerce
+packDirStream = DirStream
 
 -- the __hscore_* functions are defined in the unix package.  We can import them and let
 -- the linker figure it out.
@@ -225,7 +221,7 @@
 
 getDirectoryContents :: RawFilePath -> IO [(DirType, RawFilePath)]
 getDirectoryContents path =
-  traverseDirectoryContents (\l e -> pure (e:l)) [] path
+  fmap reverse $ traverseDirectoryContents (\l e -> pure (e:l)) [] path
 
 -- | return the canonicalized absolute pathname
 --
