Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hanshoglund/299164ae4a0e74ab1629854e5255391f to your computer and use it in GitHub Desktop.
Save hanshoglund/299164ae4a0e74ab1629854e5255391f to your computer and use it in GitHub Desktop.
data FileOrDir = File | Dir
-- Valid path
data Path :: FileOrDir -> * where
F :: Text -> Path File
D :: Text -> Path Dir
data Exists :: FileOrDir -> * where
FE :: Exists File
DE :: Exists Dir
data NIO
fileName :: Text -> Maybe Name
pathFile :: Text -> Maybe (Path File)
pathDir :: Text -> Maybe (Path Dir)
:: Path Dir -> Name -> Path Dir
:: Path Dir -> Name -> Path File
parent :: Path a -> Maybe (Path Dir) -- Nothing for root dir
-- volumes?
Run with a temporary path that has NO file (e.g. no meta or contents) when created.
The directory of the file exists.
Whatever bytes/meta are placed here are recycled on scope end.
withTempFile :: (Path File -> m a) -> m LowlevelError a
Run with a temporary path that has NO file (e.g. no meta or contents) when created.
Whatever bytes/meta are placed here are recycled on scope end.
withTempDir :: (Path Dir -> m a) -> m LowlevelError a
There always create parents if necessary.
createDirIn :: Path Dir -> Name -> NIO (DirExits|Exists FileOrDir|LowlevelError) ()
createDir :: Path a -> NIO (Exists a + LowlevelError) ()
remove :: Path a -> NIO (WrongFileOrDirType + NothingToRemove + LowlevelError) ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment