packages feed

atelier-core 1.0.0.0 → 1.1.0.0

raw patch · 25 files changed

+2366/−196 lines, 25 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Atelier.Effects.FSNotify: [eventIsDirectory] :: Event -> EventIsDirectory
- Atelier.Effects.FSNotify: [eventPath] :: Event -> FilePath
- Atelier.Effects.FSNotify: [eventString] :: Event -> String
- Atelier.Effects.FSNotify: [eventTime] :: Event -> UTCTime
- Atelier.Effects.File: AppendMode :: IOMode
- Atelier.Effects.File: BlockBuffering :: Maybe Int -> BufferMode
- Atelier.Effects.File: LineBuffering :: BufferMode
- Atelier.Effects.File: NoBuffering :: BufferMode
- Atelier.Effects.File: ReadMode :: IOMode
- Atelier.Effects.File: ReadWriteMode :: IOMode
- Atelier.Effects.File: WriteMode :: IOMode
- Atelier.Effects.File: data BufferMode
- Atelier.Effects.File: data File (a :: Type -> Type) b
- Atelier.Effects.File: data Handle
- Atelier.Effects.File: data IOMode
- Atelier.Effects.File: hClose :: forall (es :: [Effect]). (File :> es, HasCallStack) => Handle -> Eff es ()
- Atelier.Effects.File: hFlush :: forall (es :: [Effect]). (File :> es, HasCallStack) => Handle -> Eff es ()
- Atelier.Effects.File: hGetLine :: forall (es :: [Effect]). (File :> es, HasCallStack) => Handle -> Eff es Text
- Atelier.Effects.File: hIsEOF :: forall (es :: [Effect]). (File :> es, HasCallStack) => Handle -> Eff es Bool
- Atelier.Effects.File: hPutLBs :: forall (es :: [Effect]). (File :> es, HasCallStack) => Handle -> LByteString -> Eff es ()
- Atelier.Effects.File: hPutLBsLn :: forall (es :: [Effect]). (File :> es, HasCallStack) => Handle -> LByteString -> Eff es ()
- Atelier.Effects.File: hPutText :: forall (es :: [Effect]). (File :> es, HasCallStack) => Handle -> Text -> Eff es ()
- Atelier.Effects.File: hPutTextLn :: forall (es :: [Effect]). (File :> es, HasCallStack) => Handle -> Text -> Eff es ()
- Atelier.Effects.File: hSetBuffering :: forall (es :: [Effect]). (File :> es, HasCallStack) => Handle -> BufferMode -> Eff es ()
- Atelier.Effects.File: run :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (File ': es) a -> Eff es a
- Atelier.Effects.File: with :: forall (es :: [Effect]) a. (File :> es, HasCallStack) => FilePath -> IOMode -> (Handle -> Eff es a) -> Eff es a
- Atelier.Effects.FileWatcher.Watch: isStrictAncestor :: FilePath -> FilePath -> Bool
- Atelier.Effects.FileWatcher.Watch: makeAbsolute :: forall (es :: [Effect]). FileSystem :> es => Watch -> Eff es Watch
+ Atelier.Effects.Exit: ExitFailure :: Int -> ExitCode
+ Atelier.Effects.Exit: ExitSuccess :: ExitCode
+ Atelier.Effects.Exit: data ExitCode
+ Atelier.Effects.FSNotify: eventPath :: Event -> Absolute
+ Atelier.Effects.FileWatcher.Event: collapse :: [(Any, Event)] -> [(Any, Event)]
+ Atelier.Effects.Handles: AbsoluteSeek :: SeekMode
+ Atelier.Effects.Handles: AppendMode :: IOMode
+ Atelier.Effects.Handles: BlockBuffering :: Maybe Int -> BufferMode
+ Atelier.Effects.Handles: LineBuffering :: BufferMode
+ Atelier.Effects.Handles: NoBuffering :: BufferMode
+ Atelier.Effects.Handles: ReadMode :: IOMode
+ Atelier.Effects.Handles: ReadWriteMode :: IOMode
+ Atelier.Effects.Handles: RelativeSeek :: SeekMode
+ Atelier.Effects.Handles: SeekFromEnd :: SeekMode
+ Atelier.Effects.Handles: WriteMode :: IOMode
+ Atelier.Effects.Handles: data BufferMode
+ Atelier.Effects.Handles: data Handle
+ Atelier.Effects.Handles: data Handles (a :: Type -> Type) b
+ Atelier.Effects.Handles: data IOMode
+ Atelier.Effects.Handles: data SeekMode
+ Atelier.Effects.Handles: hClose :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> Eff es ()
+ Atelier.Effects.Handles: hFlush :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> Eff es ()
+ Atelier.Effects.Handles: hGetLine :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> Eff es Text
+ Atelier.Effects.Handles: hIsEOF :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> Eff es Bool
+ Atelier.Effects.Handles: hPutLBs :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> LByteString -> Eff es ()
+ Atelier.Effects.Handles: hPutLBsLn :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> LByteString -> Eff es ()
+ Atelier.Effects.Handles: hPutText :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> Text -> Eff es ()
+ Atelier.Effects.Handles: hPutTextLn :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> Text -> Eff es ()
+ Atelier.Effects.Handles: hSeek :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> SeekMode -> Integer -> Eff es ()
+ Atelier.Effects.Handles: hSetBuffering :: forall (es :: [Effect]). (Handles :> es, HasCallStack) => Handle -> BufferMode -> Eff es ()
+ Atelier.Effects.Handles: run :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (Handles ': es) a -> Eff es a
+ Atelier.Effects.Handles: with :: forall (es :: [Effect]) a. (Handles :> es, HasCallStack) => Absolute -> IOMode -> (Handle -> Eff es a) -> Eff es a
+ Atelier.FileSystem.Directory: XdgCache :: XdgDirectory
+ Atelier.FileSystem.Directory: XdgConfig :: XdgDirectory
+ Atelier.FileSystem.Directory: XdgConfigDirs :: XdgDirectoryList
+ Atelier.FileSystem.Directory: XdgData :: XdgDirectory
+ Atelier.FileSystem.Directory: XdgDataDirs :: XdgDirectoryList
+ Atelier.FileSystem.Directory: XdgState :: XdgDirectory
+ Atelier.FileSystem.Directory: class Actions (es :: [Effect]) path
+ Atelier.FileSystem.Directory: create :: Actions es path => path -> Eff es ()
+ Atelier.FileSystem.Directory: createIfMissing :: Actions es path => Bool -> path -> Eff es ()
+ Atelier.FileSystem.Directory: data XdgDirectory
+ Atelier.FileSystem.Directory: data XdgDirectoryList
+ Atelier.FileSystem.Directory: exists :: Actions es path => path -> Eff es Bool
+ Atelier.FileSystem.Directory: getAppUserData :: forall (es :: [Effect]). FileSystem :> es => Relative -> Eff es Absolute
+ Atelier.FileSystem.Directory: getContents :: Actions es path => path -> Eff es [Relative]
+ Atelier.FileSystem.Directory: getCurrent :: forall (es :: [Effect]). FileSystem :> es => Eff es Absolute
+ Atelier.FileSystem.Directory: getHome :: forall (es :: [Effect]). FileSystem :> es => Eff es Absolute
+ Atelier.FileSystem.Directory: getTemporary :: forall (es :: [Effect]). FileSystem :> es => Eff es Absolute
+ Atelier.FileSystem.Directory: getUserDocuments :: forall (es :: [Effect]). FileSystem :> es => Eff es Absolute
+ Atelier.FileSystem.Directory: getXdg :: forall (es :: [Effect]). FileSystem :> es => XdgDirectory -> Relative -> Eff es Absolute
+ Atelier.FileSystem.Directory: getXdgList :: forall (es :: [Effect]). FileSystem :> es => XdgDirectoryList -> Eff es [Absolute]
+ Atelier.FileSystem.Directory: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.Directory.Actions es Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.Directory: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.Directory.Actions es Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.Directory: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.Directory.Actions es Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.Directory: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.Directory.Actions es (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.Directory: list :: Actions es path => path -> Eff es [Relative]
+ Atelier.FileSystem.Directory: remove :: Actions es path => path -> Eff es ()
+ Atelier.FileSystem.Directory: removeRecursive :: Actions es path => path -> Eff es ()
+ Atelier.FileSystem.Directory: rename :: Actions es path => path -> path -> Eff es ()
+ Atelier.FileSystem.Directory: setCurrent :: Actions es path => path -> Eff es ()
+ Atelier.FileSystem.Directory: withCurrent :: Actions es path => path -> Eff es a -> Eff es a
+ Atelier.FileSystem.File: class Actions (es :: [Effect]) path
+ Atelier.FileSystem.File: class ReadFile (es :: [Effect]) output path
+ Atelier.FileSystem.File: class WriteFile (es :: [Effect]) input path
+ Atelier.FileSystem.File: copy :: Actions es path => path -> path -> Eff es ()
+ Atelier.FileSystem.File: copyWithMetadata :: Actions es path => path -> path -> Eff es ()
+ Atelier.FileSystem.File: exists :: Actions es path => path -> Eff es Bool
+ Atelier.FileSystem.File: getAccessTime :: Actions es path => path -> Eff es UTCTime
+ Atelier.FileSystem.File: getModificationTime :: Actions es path => path -> Eff es UTCTime
+ Atelier.FileSystem.File: getSize :: Actions es path => path -> Eff es Integer
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.Actions es Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.Actions es Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es Data.ByteString.Internal.Type.ByteString Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es Data.ByteString.Internal.Type.ByteString Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es Data.ByteString.Internal.Type.ByteString Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es Data.Text.Internal.Text Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es Data.Text.Internal.Text Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es Data.Text.Internal.Text Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es GHC.Base.String Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es GHC.Base.String Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es GHC.Base.String Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es Relude.String.Conversion.LByteString Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es Relude.String.Conversion.LByteString Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.ReadFile es Relude.String.Conversion.LByteString Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es Data.ByteString.Internal.Type.ByteString Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es Data.ByteString.Internal.Type.ByteString Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es Data.ByteString.Internal.Type.ByteString Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es Data.Text.Internal.Text Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es Data.Text.Internal.Text Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es Data.Text.Internal.Text Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es GHC.Base.String Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es GHC.Base.String Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es GHC.Base.String Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es Relude.String.Conversion.LByteString Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es Relude.String.Conversion.LByteString Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.File.WriteFile es Relude.String.Conversion.LByteString Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.File.ReadFile es Data.ByteString.Internal.Type.ByteString (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.File.ReadFile es Data.Text.Internal.Text (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.File.ReadFile es GHC.Base.String (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.File.ReadFile es Relude.String.Conversion.LByteString (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.File.WriteFile es Data.ByteString.Internal.Type.ByteString (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.File.WriteFile es Data.Text.Internal.Text (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.File.WriteFile es GHC.Base.String (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.File: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.File.WriteFile es Relude.String.Conversion.LByteString (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.File: read :: ReadFile es output path => path -> Eff es output
+ Atelier.FileSystem.File: remove :: Actions es path => path -> Eff es ()
+ Atelier.FileSystem.File: rename :: Actions es path => path -> path -> Eff es ()
+ Atelier.FileSystem.File: setAccessTime :: Actions es path => path -> UTCTime -> Eff es ()
+ Atelier.FileSystem.File: setModificationTime :: Actions es path => path -> UTCTime -> Eff es ()
+ Atelier.FileSystem.File: write :: WriteFile es input path => path -> input -> Eff es ()
+ Atelier.FileSystem.Path: (-<.>) :: Path path => path -> String -> path
+ Atelier.FileSystem.Path: (<.>) :: Path path => path -> String -> path
+ Atelier.FileSystem.Path: (</>) :: Path path => path -> Relative -> path
+ Atelier.FileSystem.Path: Absolute :: Absolute -> Any
+ Atelier.FileSystem.Path: Relative :: Relative -> Any
+ Atelier.FileSystem.Path: abs :: forall (s :: Symbol). (KnownSymbol s, StartsWithSlash s) => Absolute
+ Atelier.FileSystem.Path: absolute :: forall (s :: Symbol). (KnownSymbol s, StartsWithSlash s) => Absolute
+ Atelier.FileSystem.Path: addExtension :: Path path => path -> String -> path
+ Atelier.FileSystem.Path: addTrailingPathSeparator :: Path path => path -> path
+ Atelier.FileSystem.Path: canonicalize :: Actions es path => path -> Eff es Absolute
+ Atelier.FileSystem.Path: class Actions (es :: [Effect]) path
+ Atelier.FileSystem.Path: class Path path
+ Atelier.FileSystem.Path: combine :: Path path => path -> Relative -> path
+ Atelier.FileSystem.Path: data Absolute
+ Atelier.FileSystem.Path: data Any
+ Atelier.FileSystem.Path: data Relative
+ Atelier.FileSystem.Path: dropExtension :: Path path => path -> path
+ Atelier.FileSystem.Path: dropExtensions :: Path path => path -> path
+ Atelier.FileSystem.Path: dropFileName :: Path path => path -> path
+ Atelier.FileSystem.Path: dropTrailingPathSeparator :: Path path => path -> path
+ Atelier.FileSystem.Path: equal :: Path path => path -> path -> Bool
+ Atelier.FileSystem.Path: exists :: forall (es :: [Effect]). FileSystem :> es => Absolute -> Eff es Bool
+ Atelier.FileSystem.Path: extSeparator :: Char
+ Atelier.FileSystem.Path: fromFilePath :: Path path => FilePath -> Either Text path
+ Atelier.FileSystem.Path: getSearchPath :: IO [FilePath]
+ Atelier.FileSystem.Path: hasExtension :: Path path => path -> Bool
+ Atelier.FileSystem.Path: hasTrailingPathSeparator :: Path path => path -> Bool
+ Atelier.FileSystem.Path: infixr 5 </>
+ Atelier.FileSystem.Path: infixr 7 <.>
+ Atelier.FileSystem.Path: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.Path.Actions es Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.Path: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.Path.Actions es Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.Path: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.Path.Actions es (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.Path: instance Atelier.FileSystem.Path.Internal.UnsafePath path => Atelier.FileSystem.Path.Path (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.Path: instance Atelier.FileSystem.Path.Path Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.Path: instance Atelier.FileSystem.Path.Path Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.Path: instance Atelier.FileSystem.Path.Path Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.Path: isExtSeparator :: Char -> Bool
+ Atelier.FileSystem.Path: isExtensionOf :: Path path => String -> path -> Bool
+ Atelier.FileSystem.Path: isPathSeparator :: Char -> Bool
+ Atelier.FileSystem.Path: isPrefixOf :: Path path => path -> path -> Bool
+ Atelier.FileSystem.Path: isSearchPathSeparator :: Char -> Bool
+ Atelier.FileSystem.Path: isSuffixOf :: Path path => Relative -> path -> Bool
+ Atelier.FileSystem.Path: isValid :: Path path => path -> Bool
+ Atelier.FileSystem.Path: joinPath :: Path path => path -> [Relative] -> path
+ Atelier.FileSystem.Path: makeAbsolute :: forall (es :: [Effect]). FileSystem :> es => Relative -> Eff es Absolute
+ Atelier.FileSystem.Path: makeRelative :: Path path => path -> path -> Relative
+ Atelier.FileSystem.Path: makeRelativeToCurrentDirectory :: forall (es :: [Effect]). FileSystem :> es => Absolute -> Eff es Relative
+ Atelier.FileSystem.Path: mapAny :: (forall path. Path path => path -> path) -> Any -> Any
+ Atelier.FileSystem.Path: normalise :: Path path => path -> path
+ Atelier.FileSystem.Path: pathSeparator :: Char
+ Atelier.FileSystem.Path: pathSeparators :: [Char]
+ Atelier.FileSystem.Path: rel :: forall (s :: Symbol). (KnownSymbol s, NoLeadingSlash s) => Relative
+ Atelier.FileSystem.Path: relative :: forall (s :: Symbol). (KnownSymbol s, NoLeadingSlash s) => Relative
+ Atelier.FileSystem.Path: removeForcibly :: Actions es path => path -> Eff es ()
+ Atelier.FileSystem.Path: rename :: Actions es path => path -> path -> Eff es ()
+ Atelier.FileSystem.Path: replaceBaseName :: Path path => path -> String -> path
+ Atelier.FileSystem.Path: replaceDirectory :: Path path => path -> path -> path
+ Atelier.FileSystem.Path: replaceExtension :: Path path => path -> String -> path
+ Atelier.FileSystem.Path: replaceExtensions :: Path path => path -> String -> path
+ Atelier.FileSystem.Path: replaceFileName :: Path path => path -> Relative -> path
+ Atelier.FileSystem.Path: searchPathSeparator :: Char
+ Atelier.FileSystem.Path: splitDirectories :: Path path => path -> (path, [Relative])
+ Atelier.FileSystem.Path: splitExtension :: Path path => path -> (path, String)
+ Atelier.FileSystem.Path: splitExtensions :: Path path => path -> (path, String)
+ Atelier.FileSystem.Path: splitFileName :: Path path => path -> (path, Relative)
+ Atelier.FileSystem.Path: splitPath :: Path path => path -> (path, [Relative])
+ Atelier.FileSystem.Path: splitSearchPath :: String -> [FilePath]
+ Atelier.FileSystem.Path: stripExtension :: Path path => String -> path -> Maybe path
+ Atelier.FileSystem.Path: takeBaseName :: Path path => path -> String
+ Atelier.FileSystem.Path: takeDirectory :: Path path => path -> path
+ Atelier.FileSystem.Path: takeExtension :: Path path => path -> String
+ Atelier.FileSystem.Path: takeExtensions :: Path path => path -> String
+ Atelier.FileSystem.Path: takeFileName :: Path path => path -> Relative
+ Atelier.FileSystem.Path: toFilePath :: Path path => path -> FilePath
+ Atelier.FileSystem.Path: type FilePath = String
+ Atelier.FileSystem.Path: withAny :: (forall path. Path path => path -> a) -> Any -> a
+ Atelier.FileSystem.Path.Symbol: abs :: forall (s :: Symbol). (KnownSymbol s, StartsWithSlash s) => Absolute
+ Atelier.FileSystem.Path.Symbol: absolute :: forall (s :: Symbol). (KnownSymbol s, StartsWithSlash s) => Absolute
+ Atelier.FileSystem.Path.Symbol: rel :: forall (s :: Symbol). (KnownSymbol s, NoLeadingSlash s) => Relative
+ Atelier.FileSystem.Path.Symbol: relative :: forall (s :: Symbol). (KnownSymbol s, NoLeadingSlash s) => Relative
+ Atelier.FileSystem.Path.Symbol: type NoLeadingSlash (s :: Symbol) = RejectSlash s UnconsSymbol s
+ Atelier.FileSystem.Path.Symbol: type StartsWithSlash (s :: Symbol) = RequireSlash s UnconsSymbol s
+ Atelier.FileSystem.Permissions: class Actions (es :: [Effect]) path
+ Atelier.FileSystem.Permissions: copy :: Actions es path => path -> path -> Eff es ()
+ Atelier.FileSystem.Permissions: data Permissions
+ Atelier.FileSystem.Permissions: emptyPermissions :: Permissions
+ Atelier.FileSystem.Permissions: get :: Actions es path => path -> Eff es Permissions
+ Atelier.FileSystem.Permissions: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.Permissions.Actions es Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.Permissions: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.Permissions.Actions es Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.Permissions: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.Permissions.Actions es Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.Permissions: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.Permissions.Actions es (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.Permissions: set :: Actions es path => path -> Permissions -> Eff es ()
+ Atelier.FileSystem.Permissions: setOwnerExecutable :: Bool -> Permissions -> Permissions
+ Atelier.FileSystem.Permissions: setOwnerReadable :: Bool -> Permissions -> Permissions
+ Atelier.FileSystem.Permissions: setOwnerSearchable :: Bool -> Permissions -> Permissions
+ Atelier.FileSystem.Permissions: setOwnerWritable :: Bool -> Permissions -> Permissions
+ Atelier.FileSystem.SymbolicLink: class Actions (es :: [Effect]) path
+ Atelier.FileSystem.SymbolicLink: create :: Actions es path => path -> path -> Eff es ()
+ Atelier.FileSystem.SymbolicLink: exists :: Actions es path => path -> Eff es Bool
+ Atelier.FileSystem.SymbolicLink: getTarget :: Actions es path => path -> Eff es Any
+ Atelier.FileSystem.SymbolicLink: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.SymbolicLink.Actions es Atelier.FileSystem.Path.Internal.Absolute
+ Atelier.FileSystem.SymbolicLink: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.SymbolicLink.Actions es Atelier.FileSystem.Path.Internal.Any
+ Atelier.FileSystem.SymbolicLink: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es) => Atelier.FileSystem.SymbolicLink.Actions es Atelier.FileSystem.Path.Internal.Relative
+ Atelier.FileSystem.SymbolicLink: instance (Effectful.FileSystem.Effect.FileSystem Effectful.Internal.Effect.:> es, Atelier.FileSystem.Path.Internal.UnsafePath path) => Atelier.FileSystem.SymbolicLink.Actions es (Atelier.FileSystem.Path.Internal.SafePath path)
+ Atelier.FileSystem.SymbolicLink: remove :: Actions es path => path -> Eff es ()
+ Atelier.Time: instance GHC.Base.Functor Atelier.Time.AsJsonMicrosecond
+ Atelier.Time: instance GHC.Base.Functor Atelier.Time.AsRawUnit
- Atelier.Effects.FSNotify: watchDir :: forall (es :: [Effect]). FSNotify :> es => WatchManager -> FilePath -> ActionPredicate -> Action es -> Eff es StopListening
+ Atelier.Effects.FSNotify: watchDir :: forall (es :: [Effect]). FSNotify :> es => WatchManager -> Absolute -> ActionPredicate -> Action es -> Eff es StopListening
- Atelier.Effects.FSNotify: watchDirChan :: forall (es :: [Effect]). FSNotify :> es => WatchManager -> FilePath -> ActionPredicate -> EventChannel -> Eff es StopListening
+ Atelier.Effects.FSNotify: watchDirChan :: forall (es :: [Effect]). FSNotify :> es => WatchManager -> Absolute -> ActionPredicate -> EventChannel -> Eff es StopListening
- Atelier.Effects.FSNotify: watchTree :: forall (es :: [Effect]). FSNotify :> es => WatchManager -> FilePath -> ActionPredicate -> Action es -> Eff es StopListening
+ Atelier.Effects.FSNotify: watchTree :: forall (es :: [Effect]). FSNotify :> es => WatchManager -> Absolute -> ActionPredicate -> Action es -> Eff es StopListening
- Atelier.Effects.FSNotify: watchTreeChan :: forall (es :: [Effect]). FSNotify :> es => WatchManager -> FilePath -> ActionPredicate -> EventChannel -> Eff es StopListening
+ Atelier.Effects.FSNotify: watchTreeChan :: forall (es :: [Effect]). FSNotify :> es => WatchManager -> Absolute -> ActionPredicate -> EventChannel -> Eff es StopListening
- Atelier.Effects.FileSystem.Glob: NextGlob :: [FilePath] -> GlobScript
+ Atelier.Effects.FileSystem.Glob: NextGlob :: [Absolute] -> GlobScript
- Atelier.Effects.FileSystem.Glob: NextGlobDir :: [[FilePath]] -> GlobScript
+ Atelier.Effects.FileSystem.Glob: NextGlobDir :: [[Absolute]] -> GlobScript
- Atelier.Effects.FileSystem.Glob: NextGlobDir1 :: [FilePath] -> GlobScript
+ Atelier.Effects.FileSystem.Glob: NextGlobDir1 :: [Absolute] -> GlobScript
- Atelier.Effects.FileSystem.Glob: NextGlobDirWith :: ([[FilePath]], Maybe [FilePath]) -> GlobScript
+ Atelier.Effects.FileSystem.Glob: NextGlobDirWith :: ([[Absolute]], Maybe [Absolute]) -> GlobScript
- Atelier.Effects.FileSystem.Glob: [GlobDir1] :: forall (a :: Type -> Type). Pattern -> FilePath -> Glob a [FilePath]
+ Atelier.Effects.FileSystem.Glob: [GlobDir1] :: forall (a :: Type -> Type). Pattern -> Absolute -> Glob a [Absolute]
- Atelier.Effects.FileSystem.Glob: [GlobDirWith] :: forall (a :: Type -> Type). GlobOptions -> [Pattern] -> FilePath -> Glob a ([[FilePath]], Maybe [FilePath])
+ Atelier.Effects.FileSystem.Glob: [GlobDirWith] :: forall (a :: Type -> Type). GlobOptions -> [Pattern] -> Absolute -> Glob a ([[Absolute]], Maybe [Absolute])
- Atelier.Effects.FileSystem.Glob: [GlobDir] :: forall (a :: Type -> Type). [Pattern] -> FilePath -> Glob a [[FilePath]]
+ Atelier.Effects.FileSystem.Glob: [GlobDir] :: forall (a :: Type -> Type). [Pattern] -> Absolute -> Glob a [[Absolute]]
- Atelier.Effects.FileSystem.Glob: [Glob] :: forall (a :: Type -> Type). String -> Glob a [FilePath]
+ Atelier.Effects.FileSystem.Glob: [Glob] :: forall (a :: Type -> Type). String -> Glob a [Absolute]
- Atelier.Effects.FileSystem.Glob: glob :: forall (es :: [Effect]). (HasCallStack, Glob :> es) => String -> Eff es [FilePath]
+ Atelier.Effects.FileSystem.Glob: glob :: forall (es :: [Effect]). (HasCallStack, Glob :> es) => String -> Eff es [Absolute]
- Atelier.Effects.FileSystem.Glob: globDir :: forall (es :: [Effect]). (HasCallStack, Glob :> es) => [Pattern] -> FilePath -> Eff es [[FilePath]]
+ Atelier.Effects.FileSystem.Glob: globDir :: forall (es :: [Effect]). (HasCallStack, Glob :> es) => [Pattern] -> Absolute -> Eff es [[Absolute]]
- Atelier.Effects.FileSystem.Glob: globDir1 :: forall (es :: [Effect]). (HasCallStack, Glob :> es) => Pattern -> FilePath -> Eff es [FilePath]
+ Atelier.Effects.FileSystem.Glob: globDir1 :: forall (es :: [Effect]). (HasCallStack, Glob :> es) => Pattern -> Absolute -> Eff es [Absolute]
- Atelier.Effects.FileSystem.Glob: globDirWith :: forall (es :: [Effect]). (HasCallStack, Glob :> es) => GlobOptions -> [Pattern] -> FilePath -> Eff es ([[FilePath]], Maybe [FilePath])
+ Atelier.Effects.FileSystem.Glob: globDirWith :: forall (es :: [Effect]). (HasCallStack, Glob :> es) => GlobOptions -> [Pattern] -> Absolute -> Eff es ([[Absolute]], Maybe [Absolute])
- Atelier.Effects.FileWatcher: deduplicateDirs :: [FilePath] -> [FilePath]
+ Atelier.Effects.FileWatcher: deduplicateDirs :: [Absolute] -> [Absolute]
- Atelier.Effects.FileWatcher: matchesAny :: [Watch] -> FilePath -> Bool
+ Atelier.Effects.FileWatcher: matchesAny :: [Watch] -> Absolute -> Bool
- Atelier.Effects.FileWatcher: runIO :: forall (es :: [Effect]) a. (Delay :> es, FSNotify :> es, FileSystem :> es) => Eff (FileWatcher ': es) a -> Eff es a
+ Atelier.Effects.FileWatcher: runIO :: forall (es :: [Effect]) a. (Delay :> es, FSNotify :> es, Log :> es) => Eff (FileWatcher ': es) a -> Eff es a
- Atelier.Effects.FileWatcher.Watch: containing :: Text -> FilePath -> Bool
+ Atelier.Effects.FileWatcher.Watch: containing :: Text -> Absolute -> Bool
- Atelier.Effects.FileWatcher.Watch: dir :: FilePath -> Watch
+ Atelier.Effects.FileWatcher.Watch: dir :: Absolute -> Watch
- Atelier.Effects.FileWatcher.Watch: dirExt :: FilePath -> Text -> Watch
+ Atelier.Effects.FileWatcher.Watch: dirExt :: Absolute -> Text -> Watch
- Atelier.Effects.FileWatcher.Watch: dirWhere :: FilePath -> (FilePath -> Bool) -> Watch
+ Atelier.Effects.FileWatcher.Watch: dirWhere :: Absolute -> (Absolute -> Bool) -> Watch
- Atelier.Effects.FileWatcher.Watch: excluding :: Watch -> (FilePath -> Bool) -> Watch
+ Atelier.Effects.FileWatcher.Watch: excluding :: Watch -> (Absolute -> Bool) -> Watch
- Atelier.Effects.FileWatcher.Watch: matches :: FilePath -> Watch -> Bool
+ Atelier.Effects.FileWatcher.Watch: matches :: Absolute -> Watch -> Bool
- Atelier.Effects.FileWatcher.Watch: path :: Watch -> FilePath
+ Atelier.Effects.FileWatcher.Watch: path :: Watch -> Absolute
- Atelier.Effects.Posix.Daemons: PidFile :: FilePath -> PidFile
+ Atelier.Effects.Posix.Daemons: PidFile :: Absolute -> PidFile
- Atelier.Effects.Posix.Daemons: [getPidFile] :: PidFile -> FilePath
+ Atelier.Effects.Posix.Daemons: [getPidFile] :: PidFile -> Absolute
- Atelier.Effects.Process: setWorkingDir :: FilePath -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
+ Atelier.Effects.Process: setWorkingDir :: Absolute -> ProcessConfig i o e -> ProcessConfig i o e

Files

CHANGELOG.md view
@@ -7,6 +7,39 @@  ## [Unreleased] +## [1.1.0.0] - 2026-11-18++### Added++- `Atelier.Time`: Added `Functor` instances for `AsRawUnit` and `AsJsonMicrosecond`.+- `Atelier.FileSystem.Path`: paths that are distinguished at the type level on+  whether they are absolute or relative, as well as operations around these+  paths lifted from `System.FilePath` and `System.Directory`.+- `Atelier.FileSystem.File`: file operations on `Atelier.FileSystem.Path`+  paths.+- `Atelier.FileSystem.Directory`: directory operations on+  `Atelier.FileSystem.Path` paths.+- `Atelier.FileSystem.SymbolicLink`: symbolic link operations on+  `Atelier.FileSystem.Path` paths.+- `Atelier.FileSystem.Permissions`: permissions operations on+  `Atelier.FileSystem.Path` paths.+- `Atelier.Effects.Exit` now re-exports `ExitCode` and its constructors.+- `Atelier.Effects.Handles.hSeek`: lifted `System.IO.hSeek`.+- `Atelier.Effects.Handles.SeekMode`: reexport from `System.IO`.+- `Atelier.Effects.FileWatcher.Event.collapse`.++### Changed++- `Atelier.Effects.File`: renamed to `Atelier.Effects.Handles`.+- `Atelier.Effects.FileWatcher.Event`: `Removed` and `Added` events merged+  together is now considered a `Modified` event. This catches atomic writes by+  editors that support writing file in that way.++### Deprecated++- `Atelier.Effects.FileSystem`: replaced by `Effectful.FileSystem` and the+  `Atelier.Effects.FileSystem.*` family of modules.+ ## [1.0.0.0] - 2026-10-29  ### Added
atelier-core.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           atelier-core-version:        1.0.0.0+version:        1.1.0.0 synopsis:       Foundational Effectful-based effects and utilities description:    Core effects and utilities for effect-based applications, built on Effectful — part of the atelier toolkit. category:       Control@@ -47,7 +47,6 @@       Atelier.Effects.Delay       Atelier.Effects.Env       Atelier.Effects.Exit-      Atelier.Effects.File       Atelier.Effects.FileSystem       Atelier.Effects.FileSystem.Glob       Atelier.Effects.FileWatcher@@ -56,6 +55,7 @@       Atelier.Effects.FSNotify       Atelier.Effects.FSNotify.Devel       Atelier.Effects.GenUUID+      Atelier.Effects.Handles       Atelier.Effects.Input       Atelier.Effects.Internal.Coroutine       Atelier.Effects.Iterator@@ -72,6 +72,13 @@       Atelier.Effects.Timeout       Atelier.Effects.Yield       Atelier.Exception+      Atelier.FileSystem.Directory+      Atelier.FileSystem.File+      Atelier.FileSystem.Path+      Atelier.FileSystem.Path.Internal+      Atelier.FileSystem.Path.Symbol+      Atelier.FileSystem.Permissions+      Atelier.FileSystem.SymbolicLink       Atelier.Signal       Atelier.Time       Atelier.Types.HttpApiDataReadShow@@ -166,6 +173,7 @@       Unit.Atelier.Effects.ConsoleSpec       Unit.Atelier.Effects.DebounceSpec       Unit.Atelier.Effects.FileSystemSpec+      Unit.Atelier.Effects.FileWatcher.EventSpec       Unit.Atelier.Effects.FileWatcherSpec       Unit.Atelier.Effects.IteratorSpec       Unit.Atelier.Effects.LogSpec
src/Atelier/Effects/Exit.hs view
@@ -5,6 +5,7 @@     , with     , success     , failure+    , ExitCode (..)        -- * Interpreters     , runIO
src/Atelier/Effects/FSNotify.hs view
@@ -2,6 +2,7 @@  module Atelier.Effects.FSNotify     ( FSNotify+    , eventPath     , withManager     , startManager     , stopManager@@ -27,6 +28,7 @@     ) import System.FSNotify hiding     ( Action+    , eventPath     , startManager     , startManagerConf     , stopManager@@ -40,7 +42,10 @@  import System.FSNotify qualified as FSNotify +import Atelier.FileSystem.Path qualified as Path+import Atelier.FileSystem.Path.Internal qualified as Path.Internal + data FSNotify :: Effect  @@ -53,6 +58,10 @@ type Action es = Event -> Eff es ()  +eventPath :: Event -> Path.Absolute+eventPath = Path.Internal.UnsafeMkAbsolute . FSNotify.eventPath++ withManager :: (FSNotify :> es) => (WatchManager -> Eff es a) -> Eff es a withManager act =     unsafeEff \env ->@@ -80,33 +89,37 @@   watchDir-    :: (FSNotify :> es) => WatchManager -> FilePath -> ActionPredicate -> Action es -> Eff es StopListening+    :: (FSNotify :> es)+    => WatchManager -> Path.Absolute -> ActionPredicate -> Action es -> Eff es StopListening watchDir watchManager filePath actionPredicate action =     unsafeEff \env ->         concUnliftIO env Persistent Unlimited \unlift ->-            FSNotify.watchDir watchManager filePath actionPredicate (unlift . action)+            FSNotify.watchDir watchManager (Path.toFilePath filePath) actionPredicate (unlift . action)   watchDirChan     :: (FSNotify :> es)-    => WatchManager -> FilePath -> ActionPredicate -> EventChannel -> Eff es StopListening+    => WatchManager -> Path.Absolute -> ActionPredicate -> EventChannel -> Eff es StopListening watchDirChan watchManager filePath actionPredicate eventChannel =-    unsafeEff_ $ FSNotify.watchDirChan watchManager filePath actionPredicate eventChannel+    unsafeEff_+        $ FSNotify.watchDirChan watchManager (Path.toFilePath filePath) actionPredicate eventChannel   watchTree-    :: (FSNotify :> es) => WatchManager -> FilePath -> ActionPredicate -> Action es -> Eff es StopListening+    :: (FSNotify :> es)+    => WatchManager -> Path.Absolute -> ActionPredicate -> Action es -> Eff es StopListening watchTree watchManager filePath actionPredicate action =     unsafeEff \env ->         concUnliftIO env Persistent Unlimited \unlift ->-            FSNotify.watchTree watchManager filePath actionPredicate (unlift . action)+            FSNotify.watchTree watchManager (Path.toFilePath filePath) actionPredicate (unlift . action)   watchTreeChan     :: (FSNotify :> es)-    => WatchManager -> FilePath -> ActionPredicate -> EventChannel -> Eff es StopListening+    => WatchManager -> Path.Absolute -> ActionPredicate -> EventChannel -> Eff es StopListening watchTreeChan watchManager filePath actionPredicate eventChannel =-    unsafeEff_ $ FSNotify.watchTreeChan watchManager filePath actionPredicate eventChannel+    unsafeEff_+        $ FSNotify.watchTreeChan watchManager (Path.toFilePath filePath) actionPredicate eventChannel   run :: (IOE :> es) => Eff (FSNotify : es) a -> Eff es a
− src/Atelier/Effects/File.hs
@@ -1,102 +0,0 @@-{-# OPTIONS_GHC -Wno-redundant-constraints #-}---- | A handle-based file IO effect.-module Atelier.Effects.File-    ( File-    , Handle-    , BufferMode (..)-    , IOMode (..)-    , with-    , hClose-    , hFlush-    , hGetLine-    , hPutText-    , hPutTextLn-    , hPutLBs-    , hPutLBsLn-    , hIsEOF-    , hSetBuffering-    , run-    )-where--import Effectful (Dispatch (..), DispatchOf, Effect, IOE)-import Effectful.Dispatch.Static-    ( SideEffects (..)-    , StaticRep-    , evalStaticRep-    , unsafeEff_-    , unsafeSeqUnliftIO-    )-import System.IO (BufferMode (..), Handle)-import Prelude--import Data.ByteString.Lazy.Char8 qualified as LB8-import Data.Text.IO qualified as TIO-import System.IO qualified as IO----- | Operations concerning file handles.-data File :: Effect---type instance DispatchOf File = Static WithSideEffects---data instance StaticRep File = File----- | Lifted `System.IO.withFile`:-with :: (File :> es, HasCallStack) => FilePath -> IOMode -> (Handle -> Eff es a) -> Eff es a-with fp m f = unsafeSeqUnliftIO \unlift -> IO.withFile fp m (unlift . f)----- | Lifted `System.IO.hClose`.-hClose :: (File :> es, HasCallStack) => Handle -> Eff es ()-hClose = unsafeEff_ . IO.hClose----- | Lifted `System.IO.hFlush`.-hFlush :: (File :> es, HasCallStack) => Handle -> Eff es ()-hFlush = unsafeEff_ . IO.hFlush----- | Lifted `System.IO.hGetLine`.-hGetLine :: (File :> es, HasCallStack) => Handle -> Eff es Text-hGetLine = unsafeEff_ . fmap toText . IO.hGetLine----- | Lifted `Data.Text.IO.hPutStr`. Encodes via the handle's text encoding,--- symmetric with `hGetLine`.-hPutText :: (File :> es, HasCallStack) => Handle -> Text -> Eff es ()-hPutText h = unsafeEff_ . TIO.hPutStr h----- | `hPutText` with a `\n` at the end.-hPutTextLn :: (File :> es, HasCallStack) => Handle -> Text -> Eff es ()-hPutTextLn h = unsafeEff_ . TIO.hPutStrLn h----- | Lifted `System.IO.hIsEOF`.-hIsEOF :: (File :> es, HasCallStack) => Handle -> Eff es Bool-hIsEOF = unsafeEff_ . IO.hIsEOF----- | Lifted `Data.ByteString.Lazy.Char8.hPutStr`.-hPutLBs :: (File :> es, HasCallStack) => Handle -> LByteString -> Eff es ()-hPutLBs h s = unsafeEff_ $ LB8.hPutStr h s----- | Lifted `System.IO.hSetBuffering`.-hSetBuffering :: (File :> es, HasCallStack) => Handle -> BufferMode -> Eff es ()-hSetBuffering h m = unsafeEff_ $ IO.hSetBuffering h m----- | `hPutLBs` with a `\n` at the end.-hPutLBsLn :: (File :> es, HasCallStack) => Handle -> LByteString -> Eff es ()-hPutLBsLn h = hPutLBs h . (<> "\n")----- | Run file operations.-run :: (HasCallStack, IOE :> es) => Eff (File : es) a -> Eff es a-run = evalStaticRep File
src/Atelier/Effects/FileSystem.hs view
@@ -5,6 +5,7 @@ -- inert results; and 'runFileSystemState' simulates a filesystem backed by an -- in-memory 'Map' for tests. 'followFile' tails a file as it grows. module Atelier.Effects.FileSystem+    {-# DEPRECATED "Use the more discrete @Atelier.FileSystem.*@ family of modules instead." #-}     ( FileSystem (..)     , readFileBs     , readFileLbsFrom@@ -97,6 +98,51 @@   makeEffect ''FileSystem+++{-# DEPRECATED readFileBs "Use 'Atelier.FileSystem.Path.File.readFile' instead." #-}+++{-# DEPRECATED readFileLbs "Use 'Atelier.FileSystem.Path.File.readFile' instead." #-}+++{-# DEPRECATED writeFileBS "Use 'Atelier.FileSystem.Path.File.writeFile' instead." #-}+++{-# DEPRECATED writeFileLBS "Use 'Atelier.FileSystem.Path.File.writeFile' instead." #-}+++{-# DEPRECATED doesFileExist "Use 'Atelier.FileSystem.Path.File.exists' instead." #-}+++{-# DEPRECATED doesDirectoryExist "Use 'Atelier.FileSystem.Path.Directory.exists' instead." #-}+++{-# DEPRECATED doesPathExist "Use 'Atelier.FileSystem.Path.exists' instead." #-}+++{-# DEPRECATED listDirectory "Use 'Atelier.FileSystem.Directory.list' instead." #-}+++{-# DEPRECATED createDirectoryIfMissing "Use 'Atelier.FileSystem.Directory.createIfMissing' instead." #-}+++{-# DEPRECATED removeFile "Use 'Atelier.FileSystem.File.remove' instead." #-}+++{-# DEPRECATED canonicalizePath "Use 'Atelier.FileSystem.Path.canonicalize' instead." #-}+++{-# DEPRECATED getCurrentDirectory "Use 'Atelier.FileSystem.Directory.getCurrent' instead." #-}+++{-# DEPRECATED getXdgRuntimeDir "Use 'Atelier.FileSystem.Directory.getXdg' instead." #-}+++{-# DEPRECATED getModificationTime "Use 'Atelier.FileSystem.File.getModificationTime' instead." #-}+++{-# DEPRECATED makeAbsolute "Use 'Atelier.FileSystem.Path.Relative.makeAbsolute' instead." #-}   -- | Read a file's full contents lazily (equivalent to reading from offset 0).
src/Atelier/Effects/FileSystem/Glob.hs view
@@ -25,16 +25,19 @@ import System.FilePath.Glob qualified as Glob import System.FilePath.Glob qualified as GlobExports hiding (glob, globDir, globDir1, globDirWith) +import Atelier.FileSystem.Path qualified as Path + data Glob :: Effect where     -- | Lifted 'Glob.globDir'.-    GlobDir :: [Pattern] -> FilePath -> Glob m [[FilePath]]+    GlobDir :: [Pattern] -> Path.Absolute -> Glob m [[Path.Absolute]]     -- | Lifted 'Glob.globDir1'.-    GlobDir1 :: Pattern -> FilePath -> Glob m [FilePath]+    GlobDir1 :: Pattern -> Path.Absolute -> Glob m [Path.Absolute]     -- | Lifted 'Glob.glob'.-    Glob :: String -> Glob m [FilePath]+    Glob :: String -> Glob m [Path.Absolute]     -- | Lifted 'Glob.globDirWith'.-    GlobDirWith :: GlobOptions -> [Pattern] -> FilePath -> Glob m ([[FilePath]], Maybe [FilePath])+    GlobDirWith+        :: GlobOptions -> [Pattern] -> Path.Absolute -> Glob m ([[Path.Absolute]], Maybe [Path.Absolute])   makeEffect ''Glob@@ -42,22 +45,45 @@  runIO :: (IOE :> es) => Eff (Glob : es) a -> Eff es a runIO = interpret_ \case-    GlobDir patterns filePath -> liftIO $ Glob.globDir patterns filePath-    GlobDir1 pattern filePath -> liftIO $ Glob.globDir1 pattern filePath-    Glob pattern -> liftIO $ Glob.glob pattern-    GlobDirWith opts patterns filePath -> liftIO $ Glob.globDirWith opts patterns filePath+    GlobDir patterns filePath ->+        -- Should be safe to use `rights` here, unless `glob` does not behave+        -- the way they describe. The only instance this is unsafe is if you+        -- pass a `Path.relative @""`, an empty relative path, which causes+        -- `glob` to use the current working directory as the prefix for the+        -- resulting matches, which makes them in actuality _absolute_ paths.+        -- Because of this gotcha, we restrict ourselves to 'Path.Absolute'+        -- here.+        fmap (fmap (rights . fmap Path.fromFilePath))+            $ liftIO+            $ Glob.globDir patterns+            $ Path.toFilePath filePath+    GlobDir1 pattern filePath ->+        fmap (rights . fmap Path.fromFilePath)+            $ liftIO+            $ Glob.globDir1 pattern+            $ Path.toFilePath filePath+    Glob pattern -> fmap (rights . fmap Path.fromFilePath) $ liftIO $ Glob.glob pattern+    GlobDirWith opts patterns filePath ->+        fmap+            ( bimap+                (fmap (rights . fmap Path.fromFilePath))+                (fmap (rights . fmap Path.fromFilePath))+            )+            $ liftIO+            $ Glob.globDirWith opts patterns+            $ Path.toFilePath filePath   -- | Script element for the test interpreter. data GlobScript     = -- | Return this result for the next 'globDir' call.-      NextGlobDir [[FilePath]]+      NextGlobDir [[Path.Absolute]]     | -- | Return this result for the next 'globDir1' call.-      NextGlobDir1 [FilePath]+      NextGlobDir1 [Path.Absolute]     | -- | Return this result for the next 'glob' call.-      NextGlob [FilePath]+      NextGlob [Path.Absolute]     | -- | Return this result for the next 'globDirWith' call.-      NextGlobDirWith ([[FilePath]], Maybe [FilePath])+      NextGlobDirWith ([[Path.Absolute]], Maybe [Path.Absolute])   -- | Scripted interpreter for testing. Pops the next matching entry off the
src/Atelier/Effects/FileWatcher.hs view
@@ -70,15 +70,17 @@ import Atelier.Effects.Debounce (Debounce) import Atelier.Effects.Delay (Delay) import Atelier.Effects.FSNotify (FSNotify)-import Atelier.Effects.FileSystem (FileSystem) import Atelier.Effects.FileWatcher.Event (Event) import Atelier.Effects.FileWatcher.Watch (Watch)+import Atelier.Effects.Log (Log)  import Atelier.Effects.Debounce qualified as Debounce import Atelier.Effects.Delay qualified as Delay import Atelier.Effects.FSNotify qualified as FSNotify import Atelier.Effects.FileWatcher.Event qualified as Event import Atelier.Effects.FileWatcher.Watch qualified as Watch+import Atelier.Effects.Log qualified as Log+import Atelier.FileSystem.Path qualified as Path import Atelier.Time qualified as Time  @@ -108,15 +110,15 @@   -- | Production interpreter backed by fsnotify.-runIO :: (Delay :> es, FSNotify :> es, FileSystem :> es) => Eff (FileWatcher : es) a -> Eff es a+runIO :: (Delay :> es, FSNotify :> es, Log :> es) => Eff (FileWatcher : es) a -> Eff es a runIO = interpret \env -> \case-    WatchFilePaths watches callback -> do-        absWatches <- forM watches Watch.makeAbsolute+    WatchFilePaths absWatches callback -> do         FSNotify.withManager \mgr -> do             let dedupedDirs = deduplicateDirs $ Watch.path <$> absWatches             localUnlift env (ConcUnlift Persistent Unlimited) \unlift ->                 for_ dedupedDirs \d ->-                    FSNotify.watchTree mgr d (matchesAny absWatches . eventPath) \fsEvent ->+                    FSNotify.watchTree mgr d (matchesAny absWatches . FSNotify.eventPath) \fsEvent -> do+                        Log.debug $ "File event: " <> show fsEvent                         void $ unlift $ callback (eventPath fsEvent) (Event.fromFS fsEvent)             -- Park indefinitely to hold the manager open. fsnotify delivers             -- events on its own threads, so there is nothing to do here, and@@ -154,12 +156,12 @@ -- Helpers  -- | Remove dirs that are proper subdirectories of another dir in the list.-deduplicateDirs :: [FilePath] -> [FilePath]+deduplicateDirs :: [Path.Absolute] -> [Path.Absolute] deduplicateDirs dirs = filter notRedundant (nub dirs)   where-    notRedundant d = not $ any (\d' -> d' /= d && Watch.isStrictAncestor d' d) dirs+    notRedundant d = not $ any (\d' -> d' /= d && Path.isPrefixOf d' d) dirs   -- | Check whether a file path matches at least one 'Watch' entry.-matchesAny :: [Watch] -> FilePath -> Bool+matchesAny :: [Watch] -> Path.Absolute -> Bool matchesAny watches path = any (Watch.matches path) watches
src/Atelier/Effects/FileWatcher/Event.hs view
@@ -2,12 +2,16 @@     ( Event (..)     , merge     , fromFS+    , collapse     ) where +import Data.List qualified as List import System.FSNotify qualified as FSN +import Atelier.FileSystem.Path qualified as Path + -- | The kind of filesystem change that triggered a watch callback. data Event     = -- | A new file was created.@@ -33,7 +37,7 @@ -- * Otherwise → the newer event. merge :: Event -> Event -> Event merge _ Removed = Removed-merge Removed Added = Added+merge Removed Added = Modified merge Added _ = Added merge _ event = event @@ -47,3 +51,14 @@     FSN.Removed {} -> Removed     FSN.WatchedDirectoryRemoved {} -> Removed     FSN.Unknown {} -> Modified+++-- | Collapse a batch of events so that each path appears once, with the events+-- it saw merged (see 'merge'). Paths are ordered by their most recent event.+collapse :: [(Path.Any, Event)] -> [(Path.Any, Event)]+collapse = foldl' step []+  where+    step acc (fp, event) =+        case List.partition ((== fp) . fst) acc of+            ([], rest) -> rest <> [(fp, event)]+            ((_, old) : _, rest) -> rest <> [(fp, merge old event)]
src/Atelier/Effects/FileWatcher/Watch.hs view
@@ -14,31 +14,24 @@        -- ** Check     , matches--      -- ** Utils-    , isStrictAncestor-    , makeAbsolute     ) where  import Data.Text qualified as T-import System.FilePath qualified as Path -import Atelier.Effects.FileSystem (FileSystem)--import Atelier.Effects.FileSystem qualified as FileSystem+import Atelier.FileSystem.Path qualified as Path   -- | Specification of a directory to watch recursively, with a file predicate.-data Watch = Watch FilePath (FilePath -> Bool)+data Watch = Watch Path.Absolute (Path.Absolute -> Bool)  -path :: Watch -> FilePath+path :: Watch -> Path.Absolute path (Watch p _) = p   -- | Watch all files in a directory recursively.-dir :: FilePath -> Watch+dir :: Path.Absolute -> Watch dir p = Watch p (const True)  @@ -47,7 +40,7 @@ -- @ -- dirWhere "src" (\f -> takeExtension f == ".hs") -- @-dirWhere :: FilePath -> (FilePath -> Bool) -> Watch+dirWhere :: Path.Absolute -> (Path.Absolute -> Bool) -> Watch dirWhere = Watch  @@ -56,7 +49,7 @@ -- @ -- dirExt "src" ".hs" -- @-dirExt :: FilePath -> Text -> Watch+dirExt :: Path.Absolute -> Text -> Watch dirExt p ext = dirWhere p (\f -> toText (Path.takeExtension f) == ext)  @@ -65,7 +58,7 @@ -- @ -- dirExt "src" ".hs" \`excluding\` containing "dist-newstyle" -- @-excluding :: Watch -> (FilePath -> Bool) -> Watch+excluding :: Watch -> (Path.Absolute -> Bool) -> Watch excluding (Watch p predicate) excl = Watch p (\f -> predicate f && not (excl f))  @@ -76,20 +69,10 @@ -- @ -- dir "src" \`excluding\` containing "dist-newstyle" -- @-containing :: Text -> FilePath -> Bool-containing fragment f = fragment `T.isInfixOf` toText f+containing :: Text -> Path.Absolute -> Bool+containing fragment f = fragment `T.isInfixOf` toText (Path.toFilePath f)  -matches :: FilePath -> Watch -> Bool+matches :: Path.Absolute -> Watch -> Bool matches filePath (Watch d predicate) =-    (d == filePath || isStrictAncestor d filePath) && predicate filePath----- | @isStrictAncestor parent child@ is true iff @parent@ is a proper ancestor--- of @child@ in the filesystem hierarchy.-isStrictAncestor :: FilePath -> FilePath -> Bool-isStrictAncestor parent child = (parent <> "/") `isPrefixOf` child---makeAbsolute :: (FileSystem :> es) => Watch -> Eff es Watch-makeAbsolute (Watch p predicate) = flip Watch predicate <$> FileSystem.makeAbsolute p+    (d == filePath || Path.isPrefixOf d filePath) && predicate filePath
+ src/Atelier/Effects/Handles.hs view
@@ -0,0 +1,110 @@+{-# OPTIONS_GHC -Wno-redundant-constraints #-}++module Atelier.Effects.Handles+    ( Handles+    , Handle+    , BufferMode (..)+    , IOMode (..)+    , SeekMode (..)+    , with+    , hClose+    , hFlush+    , hSeek+    , hGetLine+    , hPutText+    , hPutTextLn+    , hPutLBs+    , hPutLBsLn+    , hIsEOF+    , hSetBuffering+    , run+    )+where++import Effectful (Dispatch (..), DispatchOf, Effect, IOE)+import Effectful.Dispatch.Static+    ( SideEffects (..)+    , StaticRep+    , evalStaticRep+    , unsafeEff_+    , unsafeSeqUnliftIO+    )+import System.IO (BufferMode (..), Handle, SeekMode (..))+import Prelude++import Data.ByteString.Lazy.Char8 qualified as LB8+import Data.Text.IO qualified as TIO+import System.IO qualified as IO++import Atelier.FileSystem.Path qualified as Path+++-- | Operations concerning file handles.+data Handles :: Effect+++type instance DispatchOf Handles = Static WithSideEffects+++data instance StaticRep Handles = Handles+++-- | Lifted `System.IO.withFile`:+with :: (Handles :> es, HasCallStack) => Path.Absolute -> IOMode -> (Handle -> Eff es a) -> Eff es a+with fp m f = unsafeSeqUnliftIO \unlift -> IO.withFile (Path.toFilePath fp) m (unlift . f)+++-- | Lifted `System.IO.hClose`.+hClose :: (Handles :> es, HasCallStack) => Handle -> Eff es ()+hClose = unsafeEff_ . IO.hClose+++-- | Lifted `System.IO.hFlush`.+hFlush :: (Handles :> es, HasCallStack) => Handle -> Eff es ()+hFlush = unsafeEff_ . IO.hFlush+++-- | Lifted `System.IO.hSeek`.+hSeek :: (Handles :> es, HasCallStack) => Handle -> SeekMode -> Integer -> Eff es ()+hSeek h sm i = unsafeEff_ $ IO.hSeek h sm i+++-- | Lifted `System.IO.hGetLine`.+hGetLine :: (Handles :> es, HasCallStack) => Handle -> Eff es Text+hGetLine = unsafeEff_ . fmap toText . IO.hGetLine+++-- | Lifted `Data.Text.IO.hPutStr`. Encodes via the handle's text encoding,+-- symmetric with `hGetLine`.+hPutText :: (Handles :> es, HasCallStack) => Handle -> Text -> Eff es ()+hPutText h = unsafeEff_ . TIO.hPutStr h+++-- | `hPutText` with a `\n` at the end.+hPutTextLn :: (Handles :> es, HasCallStack) => Handle -> Text -> Eff es ()+hPutTextLn h = unsafeEff_ . TIO.hPutStrLn h+++-- | Lifted `System.IO.hIsEOF`.+hIsEOF :: (Handles :> es, HasCallStack) => Handle -> Eff es Bool+hIsEOF = unsafeEff_ . IO.hIsEOF+++-- | Lifted `Data.ByteString.Lazy.Char8.hPutStr`.+hPutLBs :: (Handles :> es, HasCallStack) => Handle -> LByteString -> Eff es ()+hPutLBs h s = unsafeEff_ $ LB8.hPutStr h s+++-- | Lifted `System.IO.hSetBuffering`.+hSetBuffering :: (Handles :> es, HasCallStack) => Handle -> BufferMode -> Eff es ()+hSetBuffering h m = unsafeEff_ $ IO.hSetBuffering h m+++-- | `hPutLBs` with a `\n` at the end.+hPutLBsLn :: (Handles :> es, HasCallStack) => Handle -> LByteString -> Eff es ()+hPutLBsLn h = hPutLBs h . (<> "\n")+++-- | Run file operations.+run :: (HasCallStack, IOE :> es) => Eff (Handles : es) a -> Eff es a+run = evalStaticRep Handles
src/Atelier/Effects/Posix/Daemons.hs view
@@ -26,7 +26,9 @@  import System.Posix.Daemon qualified as Daemons +import Atelier.FileSystem.Path qualified as Path + -- | Effect for managing detached daemon processes. data Daemons :: Effect @@ -38,7 +40,7 @@   -- | The path to a daemon's PID file, used to track and control it.-newtype PidFile = PidFile {getPidFile :: FilePath}+newtype PidFile = PidFile {getPidFile :: Path.Absolute}   -- | Daemonize the given program, ensuring it is cleanly separated from the@@ -48,7 +50,7 @@     Daemons <- getStaticRep     unsafeEff \env ->         concUnliftIO env Persistent Unlimited \unlift -> do-            Daemons.runDetached (Just pidFile) def+            Daemons.runDetached (Just $ Path.toFilePath pidFile) def                 $ unlift program  @@ -56,14 +58,14 @@ isRunning :: (Daemons :> es) => PidFile -> Eff es Bool isRunning (PidFile pidFile) = do     Daemons <- getStaticRep-    unsafeEff_ $ Daemons.isRunning pidFile+    unsafeEff_ $ Daemons.isRunning $ Path.toFilePath pidFile   -- | Kill the daemon associated with the provided PID file using `SIGKILL`. forceKillAndWait :: (Daemons :> es) => PidFile -> Eff es (Either SomeException ()) forceKillAndWait (PidFile pidFile) = do     Daemons <- getStaticRep-    trySync $ unsafeEff_ $ Daemons.brutalKill pidFile+    trySync $ unsafeEff_ $ Daemons.brutalKill $ Path.toFilePath pidFile   run :: (IOE :> es) => Eff (Daemons : es) a -> Eff es a
src/Atelier/Effects/Process.hs view
@@ -59,7 +59,6 @@     , setStderr     , setStdin     , setStdout-    , setWorkingDir     , shell     ) @@ -68,7 +67,9 @@  import Atelier.Effects.Process.Internal (RunningProcess (..)) +import Atelier.FileSystem.Path qualified as Path + -- | The process's stdin stream (its type set by the 'ProcessConfig'). getStdin :: RunningProcess i o e -> i getStdin (RunningProcess p) = TP.getStdin p@@ -91,6 +92,10 @@   data instance StaticRep Process = Process+++setWorkingDir :: Path.Absolute -> ProcessConfig i o e -> ProcessConfig i o e+setWorkingDir path = TP.setWorkingDir (Path.toFilePath path)   -- | Run a process in its own process group, terminating the /whole group/ — the
+ src/Atelier/FileSystem/Directory.hs view
@@ -0,0 +1,152 @@+{-# LANGUAGE UndecidableInstances #-}++-- |+-- Module      : Atelier.FileSystem.Directory+-- Description : File system operations on directories using the path types+--               from "Atelier.FileSystem.Path".+-- Copyright   : (c) <Tweag> 2026+-- License     : MIT+-- Maintainer  : <victor.bakke@tweag.io>+--+-- Functions on directories from "Effectful.FileSystem" lifted for use with+-- "Atelier.FileSystem.Path" paths.+module Atelier.FileSystem.Directory+    ( -- * Actions on directories+      Actions+    , exists+    , create+    , createIfMissing+    , remove+    , removeRecursive+    , rename+    , list+    , getContents++      -- * Pre-defined directories+    , getHome+    , XdgDirectory (..)+    , getXdg+    , XdgDirectoryList (..)+    , getXdgList+    , getAppUserData+    , getUserDocuments+    , getTemporary++      -- * Current working directory+    , getCurrent+    , setCurrent+    , withCurrent+    )+where++import Effectful.FileSystem (FileSystem, XdgDirectory, XdgDirectoryList)+import Prelude hiding (Any (..))++import Effectful.FileSystem qualified as FileSystem++import Atelier.FileSystem.Path.Internal+    ( Absolute (..)+    , Any (..)+    , Relative (..)+    , SafePath (..)+    , UnsafePath (..)+    )+++class Actions es path where+    -- | Lifted 'Effectful.FileSystem.doesDirectoryExist'.+    exists :: path -> Eff es Bool+++    -- | Lifted 'Effectful.FileSystem.createDirectory'.+    create :: path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.createDirectoryIfMissing'.+    createIfMissing :: Bool -> path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.removeDirectory'.+    remove :: path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.removeDirectoryRecursive'.+    removeRecursive :: path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.renameDirectory'.+    rename :: path -> path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.listDirectory'.+    list :: path -> Eff es [Relative]+++    -- | Lifted 'Effectful.FileSystem.getDirectoryContents'.+    getContents :: path -> Eff es [Relative]+++    -- | Lifted 'Effectful.FileSystem.setCurrentDirectory'.+    setCurrent :: path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.withCurrentDirectory'.+    withCurrent :: path -> Eff es a -> Eff es a+++instance (FileSystem :> es, UnsafePath path) => Actions es (SafePath path) where+    create = FileSystem.createDirectory . unsafeFromPath . getSafePath+    createIfMissing createParents = FileSystem.createDirectoryIfMissing createParents . unsafeFromPath . getSafePath+    remove = FileSystem.removeDirectory . unsafeFromPath . getSafePath+    removeRecursive = FileSystem.removeDirectoryRecursive . unsafeFromPath . getSafePath+    rename = FileSystem.renameDirectory `on` (unsafeFromPath . getSafePath)+    list = fmap (fmap UnsafeMkRelative) . FileSystem.listDirectory . unsafeFromPath . getSafePath+    getContents = fmap (fmap UnsafeMkRelative) . FileSystem.getDirectoryContents . unsafeFromPath . getSafePath+    setCurrent = FileSystem.setCurrentDirectory . unsafeFromPath . getSafePath+    withCurrent = FileSystem.withCurrentDirectory . unsafeFromPath . getSafePath+    exists = FileSystem.doesDirectoryExist . unsafeFromPath . getSafePath+++deriving via (SafePath Absolute) instance (FileSystem :> es) => Actions es Absolute+++deriving via (SafePath Relative) instance (FileSystem :> es) => Actions es Relative+++deriving via (SafePath Any) instance (FileSystem :> es) => Actions es Any+++-- | Lifted 'Effectful.FileSystem.getHomeDirectory'.+getHome :: (FileSystem :> es) => Eff es Absolute+getHome = UnsafeMkAbsolute <$> FileSystem.getHomeDirectory+++-- | Lifted 'Effectful.FileSystem.getXdgDirectory'.+getXdg :: (FileSystem :> es) => XdgDirectory -> Relative -> Eff es Absolute+getXdg xdgDirectory (UnsafeMkRelative path) =+    UnsafeMkAbsolute <$> FileSystem.getXdgDirectory xdgDirectory path+++-- | Lifted 'Effectful.FileSystem.getXdgDirectoryList'.+getXdgList :: (FileSystem :> es) => XdgDirectoryList -> Eff es [Absolute]+getXdgList = fmap (fmap UnsafeMkAbsolute) . FileSystem.getXdgDirectoryList+++-- | Lifted 'Effectful.FileSystem.getAppUserDataDirectory'.+getAppUserData :: (FileSystem :> es) => Relative -> Eff es Absolute+getAppUserData = fmap UnsafeMkAbsolute . FileSystem.getAppUserDataDirectory . unsafeGetRelative+++-- | Lifted 'Effectful.FileSystem.getUserDocumentsDirectory'.+getUserDocuments :: (FileSystem :> es) => Eff es Absolute+getUserDocuments = UnsafeMkAbsolute <$> FileSystem.getUserDocumentsDirectory+++-- | Lifted 'Effectful.FileSystem.getTemporaryDirectory'.+getTemporary :: (FileSystem :> es) => Eff es Absolute+getTemporary = UnsafeMkAbsolute <$> FileSystem.getTemporaryDirectory+++-- | Lifted 'Effectful.FileSystem.getCurrentDirectory'.+getCurrent :: (FileSystem :> es) => Eff es Absolute+getCurrent = UnsafeMkAbsolute <$> FileSystem.getCurrentDirectory
+ src/Atelier/FileSystem/File.hs view
@@ -0,0 +1,252 @@+{-# LANGUAGE UndecidableInstances #-}++-- |+-- Module      : Atelier.FileSystem.File+-- Description : File system operations on files using the path types from+--               "Atelier.FileSystem.Path".+-- Copyright   : (c) <Tweag> 2026+-- License     : MIT+-- Maintainer  : <victor.bakke@tweag.io>+--+-- Functions on files from "Effectful.FileSystem" lifted for use with+-- "Atelier.FileSystem.Path" paths.+module Atelier.FileSystem.File+    ( -- * Actions on files+      Actions+    , exists+    , remove+    , rename+    , copy+    , copyWithMetadata+    , getSize++      -- * Timestamps+    , getAccessTime+    , setAccessTime+    , getModificationTime+    , setModificationTime++      -- * File contents+    , ReadFile (..)+    , WriteFile (..)+    )+where++import Data.Time (UTCTime)+import Effectful.Dispatch.Static (StaticRep, getStaticRep, unsafeEff_)+import Effectful.FileSystem (FileSystem)+import Prelude hiding (Any (..))++import Data.ByteString.Char8 qualified as B8+import Data.ByteString.Lazy.Char8 qualified as BL8+import Data.Text.IO qualified as Text.IO+import Effectful.FileSystem qualified as FileSystem+import System.IO qualified as IO++import Atelier.FileSystem.Path.Internal+    ( Absolute (..)+    , Any (..)+    , Relative (..)+    , SafePath (..)+    , UnsafePath (..)+    , unsafeFromPath+    )+++class Actions es path where+    -- | Lifted 'Effectful.FileSystem.doesFileExist'.+    exists :: path -> Eff es Bool+++    -- | Lifted 'Effectful.FileSystem.removeFile'.+    remove :: path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.renameFile'.+    rename :: path -> path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.copyFile'.+    copy :: path -> path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.copyFileWithMetadata'.+    copyWithMetadata :: path -> path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.getFileSize'.+    getSize :: path -> Eff es Integer+++    -- | Lifted 'Effectful.FileSystem.getAccessTime'.+    getAccessTime :: path -> Eff es UTCTime+++    -- | Lifted 'Effectful.FileSystem.setAccessTime'.+    setAccessTime :: path -> UTCTime -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.getModificationTime'.+    getModificationTime :: path -> Eff es UTCTime+++    -- | Lifted 'Effectful.FileSystem.setModificationTime'.+    setModificationTime :: path -> UTCTime -> Eff es ()+++instance (FileSystem :> es) => Actions es Absolute where+    exists = FileSystem.doesFileExist . unsafeGetAbsolute+    remove = FileSystem.removeFile . unsafeGetAbsolute+    rename = FileSystem.renameFile `on` unsafeGetAbsolute+    copy = FileSystem.copyFile `on` unsafeGetAbsolute+    copyWithMetadata = FileSystem.copyFileWithMetadata `on` unsafeGetAbsolute+    getSize = FileSystem.getFileSize . unsafeGetAbsolute+    getAccessTime = FileSystem.getAccessTime . unsafeGetAbsolute+    setAccessTime = FileSystem.setAccessTime . unsafeGetAbsolute+    getModificationTime = FileSystem.getModificationTime . unsafeGetAbsolute+    setModificationTime = FileSystem.setModificationTime . unsafeGetAbsolute+++instance (FileSystem :> es) => Actions es Relative where+    exists = FileSystem.doesFileExist . unsafeGetRelative+    remove = FileSystem.removeFile . unsafeGetRelative+    rename = FileSystem.renameFile `on` unsafeGetRelative+    copy = FileSystem.copyFile `on` unsafeGetRelative+    copyWithMetadata = FileSystem.copyFileWithMetadata `on` unsafeGetRelative+    getSize = FileSystem.getFileSize . unsafeGetRelative+    getAccessTime = FileSystem.getAccessTime . unsafeGetRelative+    setAccessTime = FileSystem.setAccessTime . unsafeGetRelative+    getModificationTime = FileSystem.getModificationTime . unsafeGetRelative+    setModificationTime = FileSystem.setModificationTime . unsafeGetRelative+++class ReadFile es output path where+    -- | 'IO.writeFile' for various formats and 'Absolute' and 'Relative'+    -- paths.+    read :: path -> Eff es output+++instance (FileSystem :> es, UnsafePath path) => ReadFile es LByteString (SafePath path) where+    read (SafePath path) = do+        _ :: StaticRep FileSystem <- getStaticRep+        unsafeEff_ $ BL8.readFile $ unsafeFromPath path+++instance (FileSystem :> es, UnsafePath path) => ReadFile es ByteString (SafePath path) where+    read (SafePath path) = do+        _ :: StaticRep FileSystem <- getStaticRep+        unsafeEff_ $ B8.readFile $ unsafeFromPath path+++instance (FileSystem :> es, UnsafePath path) => ReadFile es String (SafePath path) where+    read (SafePath path) = do+        _ :: StaticRep FileSystem <- getStaticRep+        unsafeEff_ $ IO.readFile $ unsafeFromPath path+++instance (FileSystem :> es, UnsafePath path) => ReadFile es Text (SafePath path) where+    read (SafePath path) = do+        _ :: StaticRep FileSystem <- getStaticRep+        unsafeEff_ $ Text.IO.readFile $ unsafeFromPath path+++deriving via (SafePath Absolute) instance (FileSystem :> es) => ReadFile es LByteString Absolute+++deriving via (SafePath Absolute) instance (FileSystem :> es) => ReadFile es ByteString Absolute+++deriving via (SafePath Absolute) instance (FileSystem :> es) => ReadFile es Text Absolute+++deriving via (SafePath Absolute) instance (FileSystem :> es) => ReadFile es String Absolute+++deriving via (SafePath Relative) instance (FileSystem :> es) => ReadFile es LByteString Relative+++deriving via (SafePath Relative) instance (FileSystem :> es) => ReadFile es ByteString Relative+++deriving via (SafePath Relative) instance (FileSystem :> es) => ReadFile es Text Relative+++deriving via (SafePath Relative) instance (FileSystem :> es) => ReadFile es String Relative+++deriving via (SafePath Any) instance (FileSystem :> es) => ReadFile es LByteString Any+++deriving via (SafePath Any) instance (FileSystem :> es) => ReadFile es ByteString Any+++deriving via (SafePath Any) instance (FileSystem :> es) => ReadFile es Text Any+++deriving via (SafePath Any) instance (FileSystem :> es) => ReadFile es String Any+++class WriteFile es input path where+    -- | 'IO.writeFile' for various input types and "Atelier.FileSystem.Path"+    -- paths.+    write :: path -> input -> Eff es ()+++instance (FileSystem :> es, UnsafePath path) => WriteFile es LByteString (SafePath path) where+    write (SafePath path) input = do+        _ :: StaticRep FileSystem <- getStaticRep+        unsafeEff_ $ BL8.writeFile (unsafeFromPath path) input+++instance (FileSystem :> es, UnsafePath path) => WriteFile es ByteString (SafePath path) where+    write (SafePath path) input = do+        _ :: StaticRep FileSystem <- getStaticRep+        unsafeEff_ $ B8.writeFile (unsafeFromPath path) input+++instance (FileSystem :> es, UnsafePath path) => WriteFile es String (SafePath path) where+    write (SafePath path) input = do+        _ :: StaticRep FileSystem <- getStaticRep+        unsafeEff_ $ IO.writeFile (unsafeFromPath path) input+++instance (FileSystem :> es, UnsafePath path) => WriteFile es Text (SafePath path) where+    write (SafePath path) input = do+        _ :: StaticRep FileSystem <- getStaticRep+        unsafeEff_ $ Text.IO.writeFile (unsafeFromPath path) input+++deriving via (SafePath Absolute) instance (FileSystem :> es) => WriteFile es LByteString Absolute+++deriving via (SafePath Absolute) instance (FileSystem :> es) => WriteFile es ByteString Absolute+++deriving via (SafePath Absolute) instance (FileSystem :> es) => WriteFile es Text Absolute+++deriving via (SafePath Absolute) instance (FileSystem :> es) => WriteFile es String Absolute+++deriving via (SafePath Relative) instance (FileSystem :> es) => WriteFile es LByteString Relative+++deriving via (SafePath Relative) instance (FileSystem :> es) => WriteFile es ByteString Relative+++deriving via (SafePath Relative) instance (FileSystem :> es) => WriteFile es Text Relative+++deriving via (SafePath Relative) instance (FileSystem :> es) => WriteFile es String Relative+++deriving via (SafePath Any) instance (FileSystem :> es) => WriteFile es LByteString Any+++deriving via (SafePath Any) instance (FileSystem :> es) => WriteFile es ByteString Any+++deriving via (SafePath Any) instance (FileSystem :> es) => WriteFile es Text Any+++deriving via (SafePath Any) instance (FileSystem :> es) => WriteFile es String Any
+ src/Atelier/FileSystem/Path.hs view
@@ -0,0 +1,1156 @@+{-# LANGUAGE UndecidableInstances #-}++-- |+-- Module      : Atelier.FileSystem.Path+-- Description : Context-aware paths to more easily distinguish absolute paths+--               from relative paths.+-- Copyright   : (c) <Tweag> 2026+-- License     : MIT+-- Maintainer  : <victor.bakke@tweag.io>+-- Portability : non-portable (requires POSIX)+--+-- Functions from "Effectful.FileSystem" tailored for use with+-- "Atelier.FileSystem.Path" paths.+--+-- As of this writing in 2026-11-06, @atelier-core@ only supports POSIX+-- systems, so we only include the POSIX examples from "System.FilePath".+-- This module also does not include or consider the Windows-specific+-- drive-related functions from `System.FilePath`. Some functions are+-- re-exported from 'System.FilePath', and thus mention Windows-specific+-- behavior.+--+-- >>> fromFilePath @Absolute "/foo"+-- Just (absolute @"/foo")+--+-- >>> fromFilePath @Absolute "foo"+-- Nothing+--+-- >>> fromFilePath @Relative "/foo"+-- Nothing+--+-- >>> fromFilePath @Relative "foo"+-- Just (relative @"foo")+--+-- >>> import Atelier.FileSystem.Path qualified as Path+-- >>> import Atelier.FileSystem.Path ((</>))+-- >>> Path.absolute @"/foo" </> Path.relative @"bar/baz"+-- Path.absolute @"/foo/bar/baz"+module Atelier.FileSystem.Path+    ( -- * Absolute paths+      Absolute++      -- ** Constructors+    , abs+    , absolute++      -- ** Converting to 'Relative'+    , makeRelativeToCurrentDirectory+    , makeRelative++      -- * Relative paths+    , Relative++      -- ** Constructors+    , rel+    , relative++      -- * Converting to 'Absolute'+    , makeAbsolute++      -- * Any path+    , Any (..)+    , mapAny+    , withAny++      -- * Conversions to/from 'FilePath'+    , toFilePath+    , fromFilePath++      -- * Checks+    , exists+    , isPrefixOf+    , isSuffixOf++      -- * Separator predicates+    , Reexports.FilePath+    , Reexports.extSeparator+    , Reexports.isExtSeparator+    , Reexports.isPathSeparator+    , Reexports.isSearchPathSeparator+    , Reexports.pathSeparator+    , Reexports.pathSeparators+    , Reexports.searchPathSeparator++      -- * \$PATH methods+    , Reexports.splitSearchPath+    , Reexports.getSearchPath++      -- * Filename/Directory functions+    , splitFileName+    , takeFileName+    , replaceFileName+    , dropFileName+    , takeBaseName+    , replaceBaseName+    , takeDirectory+    , replaceDirectory++      -- * File extension+    , splitExtension+    , takeExtension+    , replaceExtension+    , (-<.>)+    , dropExtension+    , addExtension+    , hasExtension+    , (<.>)+    , splitExtensions+    , dropExtensions+    , takeExtensions+    , replaceExtensions+    , isExtensionOf+    , stripExtension++      -- * Combining+    , combine+    , (</>)+    , joinPath++      -- * Splitting+    , splitPath+    , splitDirectories++      -- * Trailing slash functions+    , hasTrailingPathSeparator+    , addTrailingPathSeparator+    , dropTrailingPathSeparator++      -- * File name manipulations+    , normalise+    , equal+    , isValid++      -- * Actions on paths+    , Actions+    , removeForcibly+    , rename+    , canonicalize++      -- * Base path class+    , Path+    )+where++import Effectful (Effect)+import Effectful.FileSystem (FileSystem)+import Prelude hiding (Any (..), abs, isPrefixOf, join)++import Data.List qualified as List+import Effectful.FileSystem qualified as FileSystem+import System.FilePath qualified as Path+import System.FilePath qualified as Reexports++import Atelier.FileSystem.Path.Internal+    ( Absolute (..)+    , Any (..)+    , Relative (..)+    , SafePath (..)+    , UnsafePath (..)+    )+import Atelier.FileSystem.Path.Symbol (abs, absolute, rel, relative)+++-- | 'FileSystem.doesPathExist' for 'Absolute' paths.+exists :: (FileSystem :> es) => Absolute -> Eff es Bool+exists = FileSystem.doesPathExist . unsafeGetAbsolute+++-- | Base path class for all general path operations.+class Path path where+    -- | Combine two paths with a path separator. The intention is that+    -- @readFile (dir \<\/\> file)@ will access the same file as+    -- @setCurrentDirectory dir; readFile file@.+    --+    -- Unlike "System.FilePath", this class\' '(</>)' only takes 'Relative'+    -- paths as its second argument, since "System.FilePath" would just return+    -- the second argument if it starts with a path separator or a drive letter+    -- (i.e. it is an absolute path).+    --+    -- >>> "/" </> "test"+    -- "/test"+    --+    -- >>> "home" </> "bob"+    -- "home/bob"+    --+    -- >>> "x:" </> "foo"+    -- "x:/foo"+    --+    -- See 'System.FilePath.</>'.+    (</>) :: path -> Relative -> path+++    -- | Split a filename into directory and file. '</>' is the inverse. The+    -- first component will often end with a trailing slash.+    --+    -- See 'System.FilePath.splitFileName'.+    splitFileName :: path -> (path, Relative)+++    -- | Get the file name.+    --+    -- See 'System.FilePath.takeFileName'.+    takeFileName :: path -> Relative+++    -- | Set the filename.+    --+    -- See 'System.FilePath.replaceFileName'.+    replaceFileName :: path -> Relative -> path+++    -- | Drop the filename. Unlike 'takeDirectory', this function will leave a+    -- trailing path separator on the directory.+    --+    -- See 'System.FilePath.dropFileName'.+    dropFileName :: path -> path+++    -- | Get the base name, without an extension or path.+    --+    -- See 'System.FilePath.takeBaseName'.+    takeBaseName :: path -> String+++    -- | Set the base name.+    --+    -- See 'System.FilePath.replaceBaseName'.+    replaceBaseName :: path -> String -> path+++    -- | Get the directory name, move up one level.+    --+    -- See 'System.FilePath.takeDirectory'.+    takeDirectory :: path -> path+++    -- | Set the directory, keeping the filename the same.+    --+    --+    -- >>> replaceDirectory "root/file.ext" "/directory/"+    -- "/directory/file.ext"+    --+    -- >>> Valid x => replaceDirectory x (takeDirectory x) `equalFilePath` x+    -- True+    --+    -- See 'System.FilePath.replaceDirectory'.+    replaceDirectory :: path -> path -> path+++    -- | An alias for '</>'.+    combine :: path -> Relative -> path+    combine = (</>)+++    -- | Split a path by the directory separator.+    --+    -- Since whether a path is determined by whether the first segment is+    -- absolute or not, this function retains the path kind for the first+    -- returned segment, while the rest of the path are 'Relative' segments.+    --+    -- >>> splitPath "/directory/file.ext"+    -- ("/", ["directory/","file.ext"])+    --+    -- >>> uncurry (:) (splitPath x)+    -- x+    --+    -- >>> splitPath "test//item/"+    -- ("test//", ["item/"])+    --+    -- >>> splitPath "test/item/file"+    -- ("test/", ["item/","file"])+    --+    -- >>> splitPath ""+    -- ("", [])+    --+    -- >>> splitPath "test"+    -- ("test", [])+    --+    -- >>> splitPath "/file/test"+    -- ("/", ["file/","test"])+    --+    -- See 'System.FilePath.splitPath'.+    splitPath :: path -> (path, [Relative])+++    -- | Join path elements back together.+    --+    -- >>> joinPath y z+    -- foldr (</>) "" (y : z)+    --+    -- >>> joinPath "/" ["directory/","file.ext"]+    -- "/directory/file.ext"+    --+    -- >>> Valid x => uncurry joinPath (splitPath x)+    -- x+    --+    -- >>> joinPath "" []+    -- ""+    --+    -- >>> joinPath "test" ["file","path"]+    -- "test/file/path"+    --+    -- See 'System.FilePath.joinPath'.+    joinPath :: path -> [Relative] -> path+++    -- | Just as 'splitPath', but don't add the trailing slashes to each element.+    --+    -- >>> splitDirectories "/directory/file.ext"+    -- ("/", ["directory","file.ext"])+    --+    -- >>> splitDirectories "test/file"+    -- ("", ["test","file"])+    --+    -- >>> splitDirectories "/test/file"+    -- ("/", ["test","file"])+    --+    -- >>> Valid x => uncurry joinPath (splitDirectories x) `equal` x+    -- True+    --+    -- >>> splitDirectories ""+    -- ("", [])+    --+    -- >>> splitDirectories "test"+    -- ("test", [])+    --+    -- >>> splitDirectories "/test///file"+    -- ("/", ["test","file"])+    --+    -- See 'System.FilePath.splitDirectories'.+    splitDirectories :: path -> (path, [Relative])+++    -- | Normalise a file+    --+    -- - @\/\/@ outside of the drive can be made blank+    -- - @\/@ -> 'pathSeparator'+    -- - @.\/@ -> @""@+    --+    -- Does not remove @".."@, because of symlinks.+    --+    --+    -- >>> normalise "/file/\\test////"+    -- "/file/\\test/"+    --+    -- >>> normalise "/file/./test"+    -- "/file/test"+    --+    -- >>> normalise "/test/file/../bob/fred/"+    -- "/test/file/../bob/fred/"+    --+    -- >>> normalise "../bob/fred/"+    -- "../bob/fred/"+    --+    -- >>> normalise "/a/../c"+    -- "/a/../c"+    --+    -- >>> normalise "./bob/fred/"+    -- "bob/fred/"+    --+    -- >>> normalise "."+    -- "."+    --+    -- >>> normalise "./"+    -- "./"+    --+    -- >>> normalise "./."+    -- "./"+    --+    -- >>> normalise "/./"+    -- "/"+    --+    -- >>> normalise "/"+    -- "/"+    --+    -- >>> normalise "bob/fred/."+    -- "bob/fred/"+    --+    -- >>> normalise "//home"+    -- "/home"+    --+    -- See 'System.FilePath.normalise'.+    normalise :: path -> path+++    -- | Equality of two @path@s. If you call 'canonicalize' first this has a+    -- much better chance of working. Note that this doesn't follow symlinks.+    --+    -- Similar to 'normalise', this does not expand @".."@, because of+    -- symlinks.+    --+    -- >>> x == y+    -- equal x y+    --+    -- >>> normalise x == normalise y+    -- equal x y+    --+    -- >>> equal "foo" "foo\/"+    -- True+    --+    -- >>> equal "\/a\/..\/c" "\/c"+    -- False+    --+    -- >>> equal "foo" "\/foo"+    -- False+    --+    -- >>> equal "foo" "FOO"+    -- False+    --+    -- See 'System.FilePath.equalFilePath'.+    equal :: path -> path -> Bool+++    -- | Is a FilePath valid, i.e. could you create a file like it? This+    -- function checks for invalid names, and invalid characters, but does not+    -- check if length limits are exceeded, as these are typically filesystem+    -- dependent.+    --+    -- >>> isValid ""+    -- False+    --+    -- >>> isValid "\0"+    -- False+    --+    -- >>> isValid "/random_ path:*"+    -- True+    --+    -- >>> isValid x+    -- not (null x)+    --+    -- See 'System.FilePath.isValid'.+    isValid :: path -> Bool+++    -- | Check whether one path is the strict parent/prefix of another.+    --+    -- >>> "/foo" `isPrefixOf` "/foo/bar"+    -- True+    --+    -- >>> "/foo/bar" `isPrefixOf` "/foo/quack"+    -- False+    --+    -- >>> "foo" `isPrefixOf` "foo/bar"+    -- True+    --+    -- >>> "foo/" `isPrefixOf` "foo/bar"+    -- True+    --+    -- >>> "foo" `isPrefixOf` "foo"+    -- True+    isPrefixOf :: path -> path -> Bool+++    -- | Check whether a relative path is the suffix of another path.+    --+    -- >>> "bar" `isSuffixOf` "bar"+    -- True+    --+    -- >>> "bar" `isSuffixOf` "foo/bar"+    -- True+    --+    -- >>> "bar" `isSuffixOf` "/foo/bar"+    -- True+    --+    -- >>> "bar" `isSuffixOf` "/foo/bar/baz"+    -- False+    isSuffixOf :: Relative -> path -> Bool+++    -- | Is an item either a directory or the last character a path separator?+    --+    -- >>> hasTrailingPathSeparator "test"+    -- False+    --+    -- >>> hasTrailingPathSeparator "test/"+    -- True+    --+    -- See 'System.FilePath.hasTrailingPathSeparator'.+    hasTrailingPathSeparator :: path -> Bool+++    -- | Add a trailing file path separator if one is not already present.+    --+    -- >>> hasTrailingPathSeparator (addTrailingPathSeparator x)+    -- True+    --+    -- >>> addTrailingPathSeparator "test/rest"+    -- "test/rest/"+    --+    -- See 'System.FilePath.addTrailingPathSeparator'.+    addTrailingPathSeparator :: path -> path+++    -- | Remove any trailing path separators+    --+    -- >>> dropTrailingPathSeparator "file/test/"+    -- "file/test"+    --+    -- >>> dropTrailingPathSeparator "/"+    -- "/"+    --+    -- >>> hasTrailingPathSeparator (dropTrailingPathSeparator x)+    -- False+    --+    -- See 'System.FilePath.dropTrailingPathSeparator'.+    dropTrailingPathSeparator :: path -> path+++    -- | Split on the extension. 'addExtension' is the inverse.+    --+    -- >>> splitExtension "/directory/path.ext"+    -- ("/directory/path",".ext")+    --+    -- >>> uncurry (<>) (splitExtension x)+    -- x+    --+    -- >>> Valid x => uncurry addExtension (splitExtension x)+    -- x+    --+    -- >>> splitExtension "file.txt"+    -- ("file",".txt")+    --+    -- >>> splitExtension "file"+    -- ("file","")+    --+    -- >>> splitExtension "file/file.txt"+    -- ("file/file",".txt")+    --+    -- >>> splitExtension "file.txt/boris"+    -- ("file.txt/boris","")+    --+    -- >>> splitExtension "file.txt/boris.ext"+    -- ("file.txt/boris",".ext")+    --+    -- >>> splitExtension "file/path.txt.bob.fred"+    -- ("file/path.txt.bob",".fred")+    --+    -- >>> splitExtension "file/path.txt/"+    -- ("file/path.txt/","")+    --+    -- See 'System.FilePath.splitExtension'.+    splitExtension :: path -> (path, String)+++    -- | Get the extension of a file, returns @""@ for no extension, @.ext@+    -- otherwise.+    --+    -- >>> takeExtension "/directory/path.ext"+    -- ".ext"+    --+    -- >>> takeExtension x+    -- snd (splitExtension x)+    --+    -- >>> Valid x => takeExtension (addExtension x "ext")+    -- ".ext"+    --+    -- >>> Valid x => takeExtension (replaceExtension x "ext")+    -- ".ext"+    --+    -- See 'System.FilePath.takeExtension'.+    takeExtension :: path -> String+++    -- | Set the extension of a file, overwriting one if already present,+    -- equivalent to '-<.>'.+    --+    -- >>> replaceExtension "/directory/path.txt" "ext"+    -- "/directory/path.ext"+    --+    -- >>> replaceExtension "/directory/path.txt" ".ext"+    -- "/directory/path.ext"+    --+    -- >>> replaceExtension "file.txt" ".bob"+    -- "file.bob"+    --+    -- >>> replaceExtension "file.txt" "bob"+    -- "file.bob"+    --+    -- >>> replaceExtension "file" ".bob"+    -- "file.bob"+    --+    -- >>> replaceExtension "file.txt" ""+    -- "file"+    --+    -- >>> replaceExtension "file.fred.bob" "txt"+    -- "file.fred.txt"+    --+    -- >>> replaceExtension x y+    -- addExtension (dropExtension x) y+    --+    -- See 'System.FilePath.replaceExtension'.+    replaceExtension :: path -> String -> path+    replaceExtension = (-<.>)+++    -- | Remove the current extension and add another, equivalent to+    -- 'replaceExtension'.+    --+    -- >>> "/directory/path.txt" -<.> "ext"+    -- "/directory/path.ext"+    --+    -- >>> "/directory/path.txt" -<.> ".ext"+    -- "/directory/path.ext"+    --+    -- >>> "foo.o" -<.> "c"+    -- "foo.c"+    --+    -- See 'System.FilePath.-<.>'.+    (-<.>) :: path -> String -> path+++    -- | Remove last extension, and the @"."@ preceding it.+    --+    -- >>> dropExtension "/directory/path.ext"+    -- "/directory/path"+    --+    -- >>> dropExtension x+    -- fst (splitExtension x)+    --+    -- See 'System.FilePath.dropExtension'.+    dropExtension :: path -> path+++    -- | Add an extension, even if there is already one there, equivalent to+    -- '<.>'.+    --+    -- >>> addExtension "/directory/path" "ext"+    -- "/directory/path.ext"+    --+    -- >>> addExtension "file.txt" "bib"+    -- "file.txt.bib"+    --+    -- >>> addExtension "file." ".bib"+    -- "file..bib"+    --+    -- >>> addExtension "file" ".bib"+    -- "file.bib"+    --+    -- >>> addExtension "/" "x"+    -- "/.x"+    --+    -- >>> addExtension x ""+    -- x+    --+    -- >>> Valid x => takeFileName (addExtension (addTrailingPathSeparator x) "ext")+    -- ".ext"+    --+    -- See 'System.FilePath.addExtension'.+    addExtension :: path -> String -> path+    addExtension = (<.>)+++    -- | Does the given filename have an extension?+    --+    -- >>> hasExtension "/directory/path.ext"+    -- True+    --+    -- >>> hasExtension "/directory/path"+    -- False+    --+    -- >>> null (takeExtension x)+    -- not (hasExtension x)+    --+    -- See 'System.FilePath.hasExtension'.+    hasExtension :: path -> Bool+++    -- | Add an extension, even if there is already one there, equivalent to+    -- 'addExtension'.+    --+    -- >>> "/directory/path" <.> "ext"+    -- "/directory/path.ext"+    --+    -- >>> "/directory/path" <.> ".ext"+    -- "/directory/path.ext"+    --+    -- See 'System.FilePath.<.>'.+    (<.>) :: path -> String -> path+++    -- | Split on all extensions.+    --+    -- >>> splitExtensions "/directory/path.ext"+    -- ("/directory/path",".ext")+    --+    -- >>> splitExtensions "file.tar.gz"+    -- ("file",".tar.gz")+    --+    -- >>> uncurry (<>) (splitExtensions x)+    -- x+    --+    -- >>> Valid x => uncurry addExtension (splitExtensions x)+    -- x+    --+    -- See 'System.FilePath.splitExtensions'.+    splitExtensions :: path -> (path, String)+++    -- | Drop all extensions.+    --+    -- >>> dropExtensions "/directory/path.ext"+    -- "/directory/path"+    --+    -- >>> dropExtensions "file.tar.gz"+    -- "file"+    --+    -- >>> hasExtension (dropExtensions x)+    -- False+    --+    -- >>> any isExtSeparator (takeFileName (dropExtensions x))+    -- False+    --+    -- See 'System.FilePath.dropExtensions'.+    dropExtensions :: path -> path+++    -- | Get all extensions.+    --+    -- >>> takeExtensions "/directory/path.ext"+    -- ".ext"+    --+    -- >>> takeExtensions "file.tar.gz"+    -- ".tar.gz"+    --+    -- See 'System.FilePath.takeExtensions'.+    takeExtensions :: path -> String+++    -- | Replace all extensions of a file with a new extension. Note that+    -- 'replaceExtension' and 'addExtension' both work for adding multiple+    -- extensions, so only required when you need to drop all extensions first.+    --+    -- >>> replaceExtensions "file.fred.bob" "txt"+    -- "file.txt"+    --+    -- >>> replaceExtensions "file.fred.bob" "tar.gz"+    -- "file.tar.gz"+    --+    -- See 'System.FilePath.replaceExtensions'.+    replaceExtensions :: path -> String -> path+++    -- | Does the given filename have the specified extension?+    --+    -- >>> "png" `isExtensionOf` "/directory/file.png"+    -- True+    --+    -- >>> ".png" `isExtensionOf` "/directory/file.png"+    -- True+    --+    -- >>> ".tar.gz" `isExtensionOf` "bar/foo.tar.gz"+    -- True+    --+    -- >>> "ar.gz" `isExtensionOf` "bar/foo.tar.gz"+    -- False+    --+    -- >>> "png" `isExtensionOf` "/directory/file.png.jpg"+    -- False+    --+    -- >>> "csv/table.csv" `isExtensionOf` "/data/csv/table.csv"+    -- False+    --+    -- See 'System.FilePath.isExtensionOf'.+    isExtensionOf :: String -> path -> Bool+++    -- | Drop the given extension from a @path@, and the @"."@ preceding it.+    -- Returns 'Nothing' if the @path@ does not have the given extension, or+    -- 'Just' and the part before the extension if it does.+    --+    -- This function can be more predictable than 'dropExtensions', especially+    -- if the filename might itself contain @.@ characters.+    --+    -- >>> stripExtension "hs.o" "foo.x.hs.o"+    -- Just "foo.x"+    --+    -- >>> stripExtension "hi.o" "foo.x.hs.o"+    -- Nothing+    --+    -- >>> dropExtension x+    -- fromJust (stripExtension (takeExtension x) x)+    --+    -- >>> dropExtensions x+    -- fromJust (stripExtension (takeExtensions x) x)+    --+    -- >>> stripExtension ".c.d" "a.b.c.d"+    -- Just "a.b"+    --+    -- >>> stripExtension ".c.d" "a.b..c.d"+    -- Just "a.b."+    --+    -- >>> stripExtension "baz" "foo.bar"+    -- Nothing+    --+    -- >>> stripExtension "bar" "foobar"+    -- Nothing+    --+    -- >>> stripExtension "" x+    -- Just x+    --+    -- See 'System.FilePath.stripExtension'.+    stripExtension :: String -> path -> Maybe path+++    -- | Contract a filename, based on a relative path. Note that the resulting+    -- path will never introduce `..` paths, as the presence of symlinks means+    -- `../b` may not reach `a/b` if it starts from `a/c`.+    --+    -- >>> makeRelative "/directory" "/directory/file.ext"+    -- "file.ext"+    --+    -- >>> Valid x => makeRelative (takeDirectory x) x `equal` takeFileName x+    -- True+    --+    -- >>> makeRelative x x+    -- "."+    --+    -- >>> Valid x y => equal x y || (isRelative x && makeRelative y x == x) || equal (y </> makeRelative y x) x+    -- True+    --+    -- >>> makeRelative "/Home" "/home/bob"+    -- "/home/bob"+    --+    -- >>> makeRelative "/home/" "/home/bob/foo/bar"+    -- "bob/foo/bar"+    --+    -- >>> makeRelative "/fred" "bob"+    -- "bob"+    --+    -- >>> makeRelative "/file/test" "/file/test/fred"+    -- "fred"+    --+    -- >>> makeRelative "/file/test" "/file/test/fred/"+    -- "fred/"+    --+    -- >>> makeRelative "some/path" "some/path/a/b/c"+    -- "a/b/c"+    --+    -- See 'System.FilePath.makeRelative'.+    makeRelative :: path -> path -> Relative+++    -- | Get the underlying 'FilePath'.+    toFilePath :: path -> FilePath+++    -- | Create a 'path' from a 'FilePath'.+    fromFilePath :: FilePath -> Either Text path+++-- | Defined as lifted operations over "System.FilePath" operations.+deriving via (SafePath Absolute) instance Path Absolute+++-- | Defined as lifted operations over "System.FilePath" operations.+deriving via (SafePath Relative) instance Path Relative+++infixr 5 </>+++infixr 7 <.>+++infixr 7 -<.>+++-- | Effectful operations on 'Path' paths. Manipulates items on the file+-- system.+class Actions es path where+    -- | 'Effectful.FileSystem.removePathForcibly' for 'Absolute' and 'Relative' paths.+    removeForcibly :: path -> Eff es ()+++    -- | 'Effectful.FileSystem.renameFile' for 'Absolute' and 'Relative' paths.+    rename :: path -> path -> Eff es ()+++    -- | 'Effectful.FileSystem.canonicalizePath' for 'Absolute' and 'Relative' paths.+    canonicalize :: path -> Eff es Absolute+++-- | Lifted operations from "Effectful.FileSystem" for 'Absolute'.+deriving via (SafePath Absolute) instance (FileSystem :> es) => Actions es Absolute+++-- | Lifted operations from "Effectful.FileSystem" for 'Relative'.+deriving via (SafePath Relative) instance (FileSystem :> es) => Actions es Relative+++-- | Convert an 'Absolute' path to a 'Relative' path relative to the current directory.+makeRelativeToCurrentDirectory :: (FileSystem :> es) => Absolute -> Eff es Relative+makeRelativeToCurrentDirectory (UnsafeMkAbsolute path) =+    UnsafeMkRelative <$> FileSystem.makeRelativeToCurrentDirectory path+++-- | Convert a 'Relative' path into an 'Absolute' path relative to the current directory.+makeAbsolute :: (FileSystem :> es) => Relative -> Eff es Absolute+makeAbsolute (UnsafeMkRelative path) = UnsafeMkAbsolute <$> FileSystem.makeAbsolute path+++-- | Convenience instance for deriving 'Path' instances with just some basic+-- operations.+instance (UnsafePath path) => Path (SafePath path) where+    SafePath p1 </> UnsafeMkRelative p2 =+        SafePath $ unsafeToPath $ unsafeFromPath p1 Path.</> p2+++    splitFileName =+        bimap (SafePath . unsafeToPath) UnsafeMkRelative+            . Path.splitFileName+            . unsafeFromPath+            . getSafePath+++    takeFileName =+        UnsafeMkRelative+            . Path.takeFileName+            . unsafeFromPath+            . getSafePath+++    replaceFileName (SafePath absPath) (UnsafeMkRelative relPath) =+        SafePath+            $ unsafeToPath+            $ Path.replaceFileName (unsafeFromPath absPath) relPath+++    dropFileName = fmap $ unsafeMapPath Path.dropFileName+++    takeBaseName = Path.takeBaseName . unsafeFromPath . getSafePath+++    replaceBaseName (SafePath path) baseName =+        SafePath+            $ unsafeToPath+            $ Path.replaceBaseName (unsafeFromPath path) baseName+++    takeDirectory = fmap $ unsafeMapPath Path.takeDirectory+++    replaceDirectory (SafePath path) (SafePath replacement) =+        SafePath+            $ unsafeToPath+            $ Path.replaceDirectory (unsafeFromPath path)+            $ unsafeFromPath replacement+++    splitPath (SafePath path) =+        case Path.splitPath $ unsafeFromPath path of+            x : xs -> (SafePath $ unsafeToPath x, UnsafeMkRelative <$> xs)+            [] -> (SafePath $ unsafeToPath "", []) -- Should never happen with an absolute path+++    joinPath (SafePath path) segments =+        SafePath+            $ unsafeToPath+            $ Path.joinPath+            $ unsafeFromPath path : (unsafeGetRelative <$> segments)+++    splitDirectories (SafePath path) =+        case Path.splitDirectories $ unsafeFromPath path of+            x : xs -> (SafePath $ unsafeToPath x, UnsafeMkRelative <$> xs)+            _ -> (SafePath $ unsafeToPath "", []) -- should never happen with an absolute path+++    normalise = fmap $ unsafeMapPath Path.normalise+++    equal = Path.equalFilePath `on` unsafeFromPath . getSafePath+++    isValid = Path.isValid . unsafeFromPath . getSafePath+++    isPrefixOf (SafePath p1) (SafePath p2) =+        Path.addTrailingPathSeparator (unsafeFromPath p1)+            `List.isPrefixOf` unsafeFromPath p2+++    isSuffixOf (UnsafeMkRelative child) (SafePath parent) =+        Path.normalise child+            `List.isSuffixOf` Path.normalise (unsafeFromPath parent)+++    hasTrailingPathSeparator =+        Path.hasTrailingPathSeparator . unsafeFromPath . getSafePath+++    addTrailingPathSeparator =+        fmap $ unsafeMapPath Path.addTrailingPathSeparator+++    dropTrailingPathSeparator =+        fmap $ unsafeMapPath Path.dropTrailingPathSeparator+++    splitExtension =+        first (SafePath . unsafeToPath)+            . Path.splitExtension+            . unsafeFromPath+            . getSafePath+++    takeExtension = Path.takeExtension . unsafeFromPath . getSafePath+++    SafePath path -<.> ext =+        SafePath $ unsafeToPath $ unsafeFromPath path Path.-<.> ext+++    dropExtension = fmap $ unsafeMapPath Path.dropExtension+++    hasExtension = Path.hasExtension . unsafeFromPath . getSafePath+++    SafePath path <.> ext =+        SafePath $ unsafeToPath $ Path.addExtension (unsafeFromPath path) ext+++    splitExtensions =+        first (SafePath . unsafeToPath)+            . Path.splitExtensions+            . unsafeFromPath+            . getSafePath+++    dropExtensions = fmap $ unsafeMapPath Path.dropExtensions+++    takeExtensions = Path.takeExtensions . unsafeFromPath . getSafePath+++    replaceExtensions (SafePath path) =+        SafePath+            . unsafeToPath+            . Path.replaceExtensions (unsafeFromPath path)+++    isExtensionOf ext = Path.isExtensionOf ext . unsafeFromPath . getSafePath+++    stripExtension ext =+        fmap (SafePath . unsafeToPath)+            . Path.stripExtension ext+            . unsafeFromPath+            . getSafePath+++    makeRelative (SafePath p1) (SafePath p2) =+        UnsafeMkRelative $ (Path.makeRelative `on` unsafeFromPath) p1 p2+++    toFilePath = unsafeFromPath . getSafePath+++    fromFilePath = fmap SafePath . safeToPath+++instance (FileSystem :> es, UnsafePath path) => Actions (es :: [Effect]) (SafePath path) where+    removeForcibly = FileSystem.removePathForcibly . unsafeFromPath . getSafePath+    rename = FileSystem.renamePath `on` unsafeFromPath . getSafePath+    canonicalize = fmap UnsafeMkAbsolute . FileSystem.canonicalizePath . unsafeFromPath . getSafePath+++-- | Simplify operations on 'Any' paths for cases where you don't need to know+-- specifically whether it's an 'Absolute' or 'Relative' path.+withAny :: (forall path. (Path path) => path -> a) -> Any -> a+withAny f = \case+    Absolute p -> f p+    Relative p -> f p+++-- | Simplify manipulating the path in an 'Any' for cases where you don't need+-- to know specifically whether it's an 'Absolute' or 'Relative' path. Usually+-- you can just use the 'Path' instance for 'Any' instead, but this function is+-- included here for completeness sake.+--+-- >>> mapAny normalise (absolute @"/foo")+mapAny :: (forall path. (Path path) => path -> path) -> Any -> Any+mapAny f = \case+    Absolute p -> Absolute $ f p+    Relative p -> Relative $ f p+++-- | Delegates to 'Absolute' and 'Relative' where applicable. Comparisons+-- return 'False' if the two 'Any's being compared have different types of+-- paths.+instance Path Any where+    Absolute p1 </> p2 = Absolute $ p1 </> p2+    Relative p1 </> p2 = Relative $ p1 </> p2+    splitFileName (Absolute p) = first Absolute $ splitFileName p+    splitFileName (Relative p) = first Relative $ splitFileName p+    takeFileName = withAny takeFileName+    replaceFileName (Absolute p1) p2 = Absolute $ replaceFileName p1 p2+    replaceFileName (Relative p1) p2 = Relative $ replaceFileName p1 p2+    dropFileName = mapAny dropFileName+    takeBaseName = withAny takeBaseName+    replaceBaseName (Absolute p) baseName = Absolute $ replaceBaseName p baseName+    replaceBaseName (Relative p) baseName = Relative $ replaceBaseName p baseName+    takeDirectory = mapAny takeDirectory+    replaceDirectory (Absolute path) (Absolute replacement) = Absolute $ replaceDirectory path replacement+    replaceDirectory (Relative path) (Relative replacement) = Relative $ replaceDirectory path replacement+    replaceDirectory (Absolute path) (Relative replacement) =+        Relative+            $ UnsafeMkRelative+            $ Path.replaceDirectory (unsafeFromPath path) (unsafeFromPath replacement)+    replaceDirectory (Relative path) (Absolute replacement) =+        Absolute+            $ UnsafeMkAbsolute+            $ Path.replaceDirectory (unsafeFromPath path) (unsafeFromPath replacement)+    splitPath (Absolute p) = first Absolute $ splitPath p+    splitPath (Relative p) = first Relative $ splitPath p+    joinPath (Absolute p) segs = Absolute $ joinPath p segs+    joinPath (Relative p) segs = Relative $ joinPath p segs+    splitDirectories (Absolute p) = first Absolute $ splitDirectories p+    splitDirectories (Relative p) = first Relative $ splitDirectories p+    normalise = mapAny normalise+    equal (Absolute p1) (Absolute p2) = equal p1 p2+    equal (Relative p1) (Relative p2) = equal p1 p2+    equal _ _ = False+    isValid = withAny isValid+    isPrefixOf (Absolute p1) (Absolute p2) = isPrefixOf p1 p2+    isPrefixOf (Relative p1) (Relative p2) = isPrefixOf p1 p2+    isPrefixOf _ _ = False+    isSuffixOf p1 (Absolute p2) = isSuffixOf p1 p2+    isSuffixOf p1 (Relative p2) = isSuffixOf p1 p2+    hasTrailingPathSeparator = withAny hasTrailingPathSeparator+    addTrailingPathSeparator = mapAny addTrailingPathSeparator+    dropTrailingPathSeparator = mapAny dropTrailingPathSeparator+    splitExtension (Absolute p) = first Absolute $ splitExtension p+    splitExtension (Relative p) = first Relative $ splitExtension p+    takeExtension = withAny takeExtension+    Absolute p -<.> ext = Absolute $ p -<.> ext+    Relative p -<.> ext = Relative $ p -<.> ext+    dropExtension = mapAny dropExtension+    hasExtension = withAny hasExtension+    Absolute p <.> ext = Absolute $ p <.> ext+    Relative p <.> ext = Relative $ p <.> ext+    splitExtensions (Absolute p) = first Absolute $ splitExtensions p+    splitExtensions (Relative p) = first Relative $ splitExtensions p+    dropExtensions = mapAny dropExtensions+    takeExtensions = withAny takeExtensions+    replaceExtensions (Absolute p) ext = Absolute $ replaceExtensions p ext+    replaceExtensions (Relative p) ext = Relative $ replaceExtensions p ext+    isExtensionOf ext = withAny (isExtensionOf ext)+    stripExtension ext (Absolute p) = Absolute <$> stripExtension ext p+    stripExtension ext (Relative p) = Relative <$> stripExtension ext p+    makeRelative p1 p2 = UnsafeMkRelative $ Path.makeRelative (toFilePath p1) (toFilePath p2)+    toFilePath = withAny toFilePath+    fromFilePath path+        | Path.isAbsolute path = Absolute <$> fromFilePath path+        | otherwise = Relative <$> fromFilePath path
+ src/Atelier/FileSystem/Path/Internal.hs view
@@ -0,0 +1,151 @@+{-# OPTIONS_HADDOCK hide #-}++-- |+-- Module      : Atelier.FileSystem.Path.Internal+-- Description : Internal types and functions to the "Atelier.FileSystem"+--               family of modules.+-- Copyright   : (c) <Tweag> 2026+-- License     : MIT+-- Maintainer  : <victor.bakke@tweag.io>+--+-- Internal types and functions for the "Atelier.FileSystem" family of modules.+-- The API of this module is considered unstable, and will not be reflected in+-- the change log or the package version of this package.+module Atelier.FileSystem.Path.Internal+    ( Absolute (..)+    , filePathToAbsolute+    , unsafeMapAbsolute+    , Relative (..)+    , filePathToRelative+    , unsafeMapRelative+    , SafePath (..)+    , UnsafePath (..)+    , Any (..)+    )+where++import Data.Aeson (FromJSON, ToJSON)+import GHC.Generics+    ( Generically (..)+    )+import Prelude hiding (Any (..))++import System.FilePath qualified as Path+import Text.Read qualified as T+++-- | A fully qualified, absolute path. Always starts with @\/@.+newtype Absolute = UnsafeMkAbsolute {unsafeGetAbsolute :: FilePath}+    deriving stock (Eq, Ord, Show)+    deriving (FromJSON, ToJSON, ToText) via FilePath+++filePathToAbsolute :: FilePath -> Either Text Absolute+filePathToAbsolute path+    | Path.isAbsolute path = Right $ UnsafeMkAbsolute $ path+    | otherwise = Left "passed path is not absolute"+++instance T.Read Absolute where+    readPrec = do+        firstChar <- T.get+        case firstChar of+            '/' -> do+                rest <- T.readPrec+                let path = '/' : rest+                if Path.isValid path+                    then pure $ UnsafeMkAbsolute path+                    else fail "Not a valid absolute path"+            _ -> fail "not an absolute path"+++unsafeMapAbsolute :: (FilePath -> FilePath) -> Absolute -> Absolute+unsafeMapAbsolute f (UnsafeMkAbsolute path) = UnsafeMkAbsolute (f path)+++-- | A relative path on the file system. Never starts with @\/@.+newtype Relative = UnsafeMkRelative {unsafeGetRelative :: FilePath}+    deriving stock (Eq, Ord, Show)+    deriving (FromJSON, ToJSON, ToText) via FilePath+++filePathToRelative :: FilePath -> Either Text Relative+filePathToRelative path+    | Path.isRelative path = Right $ UnsafeMkRelative path+    | otherwise = Left "passed path is not relative"+++instance T.Read Relative where+    readPrec = do+        firstChar <- T.get+        case firstChar of+            '/' -> fail "not a relative path"+            x -> do+                rest <- T.readPrec+                let path = x : rest+                if Path.isValid path+                    then pure $ UnsafeMkRelative path+                    else fail "Not a valid relative path"+++unsafeMapRelative :: (FilePath -> FilePath) -> Relative -> Relative+unsafeMapRelative f (UnsafeMkRelative path) = UnsafeMkRelative (f path)+++-- | Convenience class for constructing and destructing 'Absolute' and+-- 'Relative' paths for use with 'SafePath'.+class UnsafePath path where+    unsafeToPath :: FilePath -> path+    unsafeFromPath :: path -> FilePath+    unsafeMapPath :: (FilePath -> FilePath) -> path -> path+    safeToPath :: FilePath -> Either Text path+++instance UnsafePath Absolute where+    unsafeToPath = UnsafeMkAbsolute+    unsafeFromPath = unsafeGetAbsolute+    unsafeMapPath = unsafeMapAbsolute+    safeToPath path+        | Path.isAbsolute path = Right $ UnsafeMkAbsolute $ path+        | otherwise = Left "passed path is not absolute"+++instance UnsafePath Relative where+    unsafeToPath = UnsafeMkRelative+    unsafeFromPath = unsafeGetRelative+    unsafeMapPath = unsafeMapRelative+    safeToPath path+        | Path.isRelative path = Right $ UnsafeMkRelative path+        | otherwise = Left "passed path is not relative"+++-- | Convenience wrapper to create simple instances for 'Absolute' and+-- 'Relative'. For internal use.+newtype SafePath path = SafePath {getSafePath :: path}+    deriving stock (Functor)+++-- | Can hold any sort of 'Path' value. Useful for heterogenous lists.+data Any+    = Absolute Absolute+    | Relative Relative+    deriving stock (Eq, Generic, Ord, Show)+    deriving (FromJSON, ToJSON) via Generically Any+++instance ToText Any where+    toText (Absolute p) = toText p+    toText (Relative p) = toText p+++instance UnsafePath Any where+    unsafeToPath f+        | "/" `isPrefixOf` f = Absolute $ UnsafeMkAbsolute f+        | otherwise = Relative $ UnsafeMkRelative f+    unsafeFromPath (Absolute p) = unsafeFromPath p+    unsafeFromPath (Relative p) = unsafeFromPath p+    unsafeMapPath f (Absolute p) = Absolute $ unsafeMapAbsolute f p+    unsafeMapPath f (Relative p) = Relative $ unsafeMapRelative f p+    safeToPath path+        | Path.isAbsolute path = Absolute <$> filePathToAbsolute path+        | otherwise = Relative <$> filePathToRelative path
+ src/Atelier/FileSystem/Path/Symbol.hs view
@@ -0,0 +1,98 @@+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# OPTIONS_GHC -Wno-redundant-constraints #-}+{-# OPTIONS_HADDOCK not-home #-}++-- |+-- Module      : Atelier.FileSystem.Path.Symbol+-- Description : 'Symbol' constructors for 'Absolute' and 'Relative'.+-- Copyright   : (c) <Tweag> 2026+-- License     : MIT+-- Maintainer  : <victor.bakke@tweag.io>+-- Stability   : experimental+-- Portability : POSIX+--+-- Internal types and functions for the @Atelier.FileSystem.*@ family+-- of modules. The API of this module is considered unstable, and will not be+-- reflected in the change log or the package version of this package.+module Atelier.FileSystem.Path.Symbol+    ( absolute+    , abs+    , relative+    , rel+    , StartsWithSlash+    , NoLeadingSlash+    )+where++import GHC.TypeLits+    ( ErrorMessage (..)+    , KnownSymbol+    , Symbol+    , TypeError+    , UnconsSymbol+    , symbolVal+    )+import Prelude hiding (abs, isPrefixOf, join)++import Atelier.FileSystem.Path.Internal+    ( Absolute (..)+    , Relative (..)+    )+++-- | Construct an 'Absolute' path from a type-level string. The string must+-- start with @/@.+--+-- >>> toText (absolute @"/usr/bin")+-- "/usr/bin"+--+-- >>> absolute @"usr/bin"+-- TypeError+absolute :: forall s. (KnownSymbol s, StartsWithSlash s) => Absolute+absolute = UnsafeMkAbsolute $ symbolVal (Proxy @s)+++-- | Alias for 'absolute'.+abs :: forall s. (KnownSymbol s, StartsWithSlash s) => Absolute+abs = absolute @s+++-- | Construct a 'Relative' path from a type-level string. The string must not+-- start with @/@, otherwise this is a type error.+--+-- >>> toText (relative @"foo/bar")+-- "foo/bar"+--+-- >>> relative @"/foo/bar"+-- TypeError+relative :: forall s. (KnownSymbol s, NoLeadingSlash s) => Relative+relative = UnsafeMkRelative $ symbolVal (Proxy @s)+++-- | Alias for 'relative'.+rel :: forall s. (KnownSymbol s, NoLeadingSlash s) => Relative+rel = relative @s+++type StartsWithSlash s = RequireSlash s (UnconsSymbol s)+++type family RequireSlash (s :: Symbol) (m :: Maybe (Char, Symbol)) :: Constraint where+    RequireSlash _ ('Just '( '/', _)) = ()+    RequireSlash s _ =+        TypeError+            ( 'Text "Absolute path must start with '/', but got: "+                :<>: 'ShowType s+            )+++type NoLeadingSlash s = RejectSlash s (UnconsSymbol s)+++type family RejectSlash (s :: Symbol) (m :: Maybe (Char, Symbol)) :: Constraint where+    RejectSlash s ('Just '( '/', _)) =+        TypeError+            ( 'Text "Relative path must not start with '/', but got: "+                :<>: 'ShowType s+            )+    RejectSlash _ _ = ()
+ src/Atelier/FileSystem/Permissions.hs view
@@ -0,0 +1,65 @@+{-# LANGUAGE UndecidableInstances #-}++-- |+-- Module      : Atelier.FileSystem.Permissions+-- Description : File system operations on permissions using the path types+--               from "Atelier.FileSystem.Path".+-- Copyright   : (c) <Tweag> 2026+-- License     : MIT+-- Maintainer  : <victor.bakke@tweag.io>+-- Portability : non-portable (requires POSIX)+--+-- Permission functions from "Effectful.FileSystem" tailored for use with+-- "Atelier.FileSystem.Path" paths.+module Atelier.FileSystem.Permissions+    ( Actions+    , get+    , set+    , copy++      -- ** Reexports+    , Reexports.Permissions (..)+    , Reexports.emptyPermissions+    , Reexports.setOwnerReadable+    , Reexports.setOwnerWritable+    , Reexports.setOwnerExecutable+    , Reexports.setOwnerSearchable+    )+where++import Effectful (Effect)+import Effectful.FileSystem (FileSystem, Permissions)+import Prelude hiding (Any (..))++import Effectful.FileSystem qualified as FileSystem+import Effectful.FileSystem qualified as Reexports++import Atelier.FileSystem.Path.Internal (Absolute, Any, Relative, SafePath (..), UnsafePath (..))+++class Actions (es :: [Effect]) path where+    -- | Lifted 'Effectful.FileSystem.getPermissions'.+    get :: path -> Eff es Permissions+++    -- | Lifted 'Effectful.FileSystem.setPermissions'.+    set :: path -> Permissions -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.copyPermissions'.+    copy :: path -> path -> Eff es ()+++instance (FileSystem :> es, UnsafePath path) => Actions es (SafePath path) where+    get (SafePath path) = FileSystem.getPermissions $ unsafeFromPath path+    set (SafePath path) permissions = FileSystem.setPermissions (unsafeFromPath path) permissions+    copy (SafePath from) (SafePath to) = FileSystem.copyPermissions (unsafeFromPath from) (unsafeFromPath to)+++deriving via SafePath Absolute instance (FileSystem :> es) => Actions es Absolute+++deriving via SafePath Relative instance (FileSystem :> es) => Actions es Relative+++deriving via SafePath Any instance (FileSystem :> es) => Actions es Any
+ src/Atelier/FileSystem/SymbolicLink.hs view
@@ -0,0 +1,78 @@+{-# LANGUAGE UndecidableInstances #-}++-- |+-- Module      : Atelier.FileSystem.SymbolicLink+-- Description : File system operations on symbolic links using the path types+--               from "Atelier.FileSystem.Path".+-- Copyright   : (c) <Tweag> 2026+-- License     : MIT+-- Maintainer  : <victor.bakke@tweag.io>+--+-- Functions on symbolic links from "Effectful.FileSystem" lifted for use with+-- "Atelier.FileSystem.Path" paths.+module Atelier.FileSystem.SymbolicLink+    ( -- * Actions on symbolic links+      Actions+    , create+    , remove+    , exists+    , getTarget+    )+where++import Effectful (Effect)+import Effectful.FileSystem (FileSystem)+import Prelude hiding (Any (..))++import Effectful.FileSystem qualified as FileSystem+import System.FilePath qualified as Path++import Atelier.FileSystem.Path.Internal+    ( Absolute (..)+    , Any (..)+    , Relative (..)+    , SafePath (..)+    , UnsafePath (..)+    )+++class Actions (es :: [Effect]) path where+    -- | Lifted 'Effectful.FileSystem.createFileLink'.+    create :: path -> path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.removeFile'.+    remove :: path -> Eff es ()+++    -- | Lifted 'Effectful.FileSystem.pathIsSymbolicLink'.+    exists :: path -> Eff es Bool+++    -- | Lifted 'Effectful.FileSystem.getSymbolicLinkTarget'.+    getTarget :: path -> Eff es Any+++instance (FileSystem :> es, UnsafePath path) => Actions es (SafePath path) where+    create = FileSystem.createFileLink `on` (unsafeFromPath . getSafePath)+    remove = FileSystem.removeFile . unsafeFromPath . getSafePath+    exists = FileSystem.pathIsSymbolicLink . unsafeFromPath . getSafePath+    getTarget = getSymbolicTarget . unsafeFromPath . getSafePath+++deriving via (SafePath Absolute) instance (FileSystem :> es) => Actions es Absolute+++deriving via (SafePath Relative) instance (FileSystem :> es) => Actions es Relative+++deriving via (SafePath Any) instance (FileSystem :> es) => Actions es Any+++getSymbolicTarget :: (FileSystem :> es) => FilePath -> Eff es Any+getSymbolicTarget path = do+    target <- FileSystem.getSymbolicLinkTarget path+    pure+        $ if Path.isRelative target+            then Relative $ UnsafeMkRelative path+            else Absolute $ UnsafeMkAbsolute path
src/Atelier/Time.hs view
@@ -46,7 +46,7 @@   newtype AsJsonMicrosecond unit = AsJsonMicrosecond {getAsJsonMicroseconds :: unit}-    deriving stock (Eq, Generic, Show)+    deriving stock (Eq, Functor, Generic, Show)   instance (TimeUnit unit) => ToJSON (AsJsonMicrosecond unit) where@@ -58,7 +58,7 @@   newtype AsRawUnit unit = AsRawUnit {getAsRawUnit :: unit}-    deriving stock (Eq, Generic, Show)+    deriving stock (Eq, Functor, Generic, Show)   instance (Integral unit) => ToJSON (AsRawUnit unit) where
test/Unit/Atelier/Effects/Cache/SingleflightSpec.hs view
@@ -16,7 +16,6 @@     ) import Atelier.Effects.Conc (Conc) import Atelier.Effects.Delay (Delay)-import Atelier.Time (Millisecond) import Atelier.Types.Semaphore (Semaphore)  import Atelier.Effects.Conc qualified as Conc@@ -108,9 +107,10 @@                 , testCase "all concurrent waiters receive the same result" $ do                     (results, execCount) <- runSingleflightTest $ do                         sem <- Sem.new-                        -- Launch concurrent requests with different delays-                        a1 <- Conc.fork $ with 1 (slowCompute sem 99)-                        Delay.wait (1 :: Millisecond) -- Ensure first request starts+                        started <- Sem.new+                        -- Launch concurrent requests once the first is in-flight+                        a1 <- Conc.fork $ with 1 (Sem.signal started >> slowCompute sem 99)+                        Sem.wait started                         a2 <- Conc.fork $ with 1 (compute 99)                         a3 <- Conc.fork $ with 1 (compute 99)                         Sem.signal sem -- Let first request continue@@ -203,7 +203,7 @@                     (result, execCount) <- runSingleflightTest $ do                         -- First request throws                         _ <--                            (with @Int @Int 1 (throwIO $ TestException "boom"))+                            with @Int @Int 1 (throwIO $ TestException "boom")                                 `catch` \(_ :: TestException) -> pure 0                         -- Second request should re-execute                         with 1 (compute 42)@@ -212,9 +212,14 @@                 , testCase "propagates exception to all concurrent waiters" $ do                     let action = runSingleflightTest $ do                             sem <- Sem.new+                            started <- Sem.new                             a1 <--                                Conc.fork $ with @Int @Int 1 (slowCompute sem 42 >> throwIO (TestException "concurrent-boom"))-                            Delay.wait (1 :: Millisecond)+                                Conc.fork+                                    $ with @Int @Int 1+                                    $ Sem.signal started+                                        >> slowCompute sem 42+                                        >> throwIO (TestException "concurrent-boom")+                            Sem.wait started                             a2 <- Conc.fork $ with @Int @Int 1 (compute 99)                             Sem.signal sem                             _ <- Conc.await a1@@ -227,9 +232,10 @@                 [ testCase "overrides result of in-flight computation" $ do                     (result, execCount) <- runSingleflightTest $ do                         sem <- Sem.new+                        started <- Sem.new                         -- Start slow computation-                        a1 <- Conc.fork $ with 1 (slowCompute sem 42)-                        Delay.wait (1 :: Millisecond) -- Let it start+                        a1 <- Conc.fork $ with 1 (Sem.signal started >> slowCompute sem 42)+                        Sem.wait started -- Let it start                         -- Update cache while computation is running                         update [(1, 999)]                         -- Both should get the updated value@@ -240,12 +246,14 @@                 , testCase "waiting requests receive updated value" $ do                     (results, execCount) <- runSingleflightTest $ do                         sem <- Sem.new-                        -- Start slow computation and waiters-                        a1 <- Conc.fork $ with 1 (slowCompute sem 42)-                        Delay.wait (1 :: Millisecond)+                        started <- Sem.new+                        -- Start slow computation; it signals once it is in-flight+                        a1 <- Conc.fork $ with 1 (Sem.signal started >> slowCompute sem 42)+                        Sem.wait started+                        -- a2 either waits on the in-flight computation or reads+                        -- the updated value; in both cases it never computes                         a2 <- Conc.fork $ with 1 (compute 42)-                        Delay.wait (1 :: Millisecond)-                        -- Update while they're all waiting/running+                        -- Update while a1 is still in-flight                         update [(1, 888)]                         Sem.signal sem                         r1 <- Conc.await a1
test/Unit/Atelier/Effects/FileSystemSpec.hs view
@@ -1,3 +1,5 @@+{-# OPTIONS_GHC -Wno-warnings-deprecations #-}+ module Unit.Atelier.Effects.FileSystemSpec (test_FileSystem) where  import Control.Exception (IOException, evaluate, try)@@ -10,6 +12,20 @@ import Data.Map.Strict qualified as M  import Atelier.Effects.FileSystem+    ( FileSystem+    , canonicalizePath+    , createDirectoryIfMissing+    , doesFileExist+    , doesPathExist+    , getCurrentDirectory+    , getXdgRuntimeDir+    , listDirectory+    , readFileBs+    , readFileLbs+    , readFileLbsFrom+    , removeFile+    , runState+    )   test_FileSystem :: TestTree
+ test/Unit/Atelier/Effects/FileWatcher/EventSpec.hs view
@@ -0,0 +1,41 @@+module Unit.Atelier.Effects.FileWatcher.EventSpec (test_Event) where++import Test.Tasty (TestTree, testGroup)+import Test.Tasty.HUnit (testCase, (@?=))++import Atelier.Effects.FileWatcher.Event (Event (..), collapse)++import Atelier.FileSystem.Path qualified as Path+++test_Event :: TestTree+test_Event =+    testGroup+        "Atelier.Effects.FileWatcher.Event"+        [ testGroup "collapse" testCollapse+        ]+++testCollapse :: [TestTree]+testCollapse =+    [ testCase "distinct paths are kept in arrival order" do+        collapse [(fileA, Modified), (fileB, Modified)]+            @?= [(fileA, Modified), (fileB, Modified)]+    , testCase "events for one path merge into a single event" do+        collapse [(fileA, Added), (fileA, Modified)]+            @?= [(fileA, Added)]+    , testCase "a removal wins over earlier events for the same path" do+        collapse [(fileA, Modified), (fileA, Removed)]+            @?= [(fileA, Removed)]+    , testCase "paths are ordered by their most recent event" do+        collapse [(fileA, Modified), (fileB, Modified), (fileA, Modified)]+            @?= [(fileB, Modified), (fileA, Modified)]+    ]+++fileA :: Path.Any+fileA = Path.Relative $ Path.rel @"./src/A.hs"+++fileB :: Path.Any+fileB = Path.Relative $ Path.rel @"./src/B.hs"
test/Unit/Atelier/Effects/FileWatcherSpec.hs view
@@ -24,6 +24,8 @@  import Atelier.Effects.FileWatcher qualified as FileWatcher import Atelier.Effects.FileWatcher.Watch qualified as Watch+import Atelier.FileSystem.Path qualified as Path+import Atelier.FileSystem.Path.Internal qualified as Path.Internal   test_FileWatcher :: TestTree@@ -48,23 +50,32 @@                 [ testCase "returns empty list unchanged" do                     deduplicateDirs [] @?= []                 , testCase "does not treat a dir as an ancestor of a similarly named dir" do-                    deduplicateDirs ["/src", "/srcover"] @?= ["/src", "/srcover"]+                    deduplicateDirs (mkAbs <$> ["/src", "/srcover"])+                        @?= (mkAbs <$> ["/src", "/srcover"])                 ]             ]         , testGroup             "matchesAny"             [ testCase "matches a file under a watched directory" do-                matchesAny [Watch.dir "/proj/src"] "/proj/src/Foo.hs"+                matchesAny+                    [Watch.dir $ mkAbs "/proj/src"]+                    (mkAbs "/proj/src/Foo.hs")                     @?= True             , testCase "does not match a relative watch dir against an absolute event path" do                 -- runFileWatcherIO must canonicalize Watch paths to absolute before                 -- calling matchesAny, because fsnotify always reports absolute paths.-                matchesAny [Watch.dir "src"] "/proj/src/Foo.hs"+                matchesAny+                    [Watch.dir $ mkAbs "src"]+                    (mkAbs "/proj/src/Foo.hs")                     @?= False             , testCase "applies the file predicate" do-                matchesAny [Watch.dirWhere "/proj/src" (\f -> ".hs" `isSuffixOf` f)] "/proj/src/Foo.hs"+                matchesAny+                    [Watch.dirWhere (mkAbs "/proj/src") (\f -> ".hs" `isSuffixOf` Path.toFilePath f)]+                    (mkAbs "/proj/src/Foo.hs")                     @?= True-                matchesAny [Watch.dirWhere "/proj/src" (\f -> ".hs" `isSuffixOf` f)] "/proj/src/Foo.js"+                matchesAny+                    [Watch.dirWhere (mkAbs "/proj/src") (\f -> ".hs" `isSuffixOf` Path.toFilePath f)]+                    (mkAbs "/proj/src/Foo.js")                     @?= False             ]         , testGroup "runFileWatcherScripted" testScripted@@ -86,7 +97,7 @@             paths <- collectPaths ["/src/Foo.hs", "/src/Bar.hs"]             paths @?= ["/src/Foo.hs", "/src/Bar.hs"]         , testCase "ignores the watch specification" do-            paths <- collectPathsWith [Watch.dir "/any"] ["/src/Foo.hs"]+            paths <- collectPathsWith [Watch.dir $ mkAbs "/any"] ["/src/Foo.hs"]             paths @?= ["/src/Foo.hs"]         , testCase "passes the full path to the callback unchanged" do             let path = "/home/user/project/src/Some/Deep/Module.hs"@@ -131,7 +142,7 @@     dirs <- forAll genDirs     let result = deduplicateDirs dirs     let pairs = [(a, b) | a <- result, b <- result, a /= b]-    all (\(a, b) -> not (isStrictAncestor a b)) pairs === True+    all (\(a, b) -> not (Path.isPrefixOf a b)) pairs === True   propCoverage :: PropertyT IO ()@@ -158,16 +169,16 @@ -- Generators -------------------------------------------------------------------------------- -genDirs :: Gen [FilePath]+genDirs :: Gen [Path.Absolute] genDirs = Gen.list (Range.linear 0 10) genAbsDir   -- Generates absolute paths like /a/b/c using short segments to encourage -- overlaps between generated paths.-genAbsDir :: Gen FilePath+genAbsDir :: Gen Path.Absolute genAbsDir = do     segments <- Gen.list (Range.linear 1 4) genSegment-    pure $ "/" <> intercalate "/" segments+    pure $ Path.Internal.UnsafeMkAbsolute $ "/" <> intercalate "/" segments   genSegment :: Gen String@@ -178,9 +189,9 @@ -- Helpers (mirror of FileWatcher internals) -------------------------------------------------------------------------------- -isStrictAncestor :: FilePath -> FilePath -> Bool-isStrictAncestor parent child = (parent <> "/") `isPrefixOf` child+isCoveredBy :: [Path.Absolute] -> Path.Absolute -> Bool+isCoveredBy result d = any (\r -> r == d || Path.isPrefixOf r d) result  -isCoveredBy :: [FilePath] -> FilePath -> Bool-isCoveredBy result d = any (\r -> r == d || isStrictAncestor r d) result+mkAbs :: FilePath -> Path.Absolute+mkAbs = Path.Internal.UnsafeMkAbsolute