{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fplugin=Polysemy.Plugin #-}
module Polysemy.Path (
Path
, Rel
, Abs
, File
, Dir
, PathException
, parseRelFile
, parseAbsFile
, parseRelDir
, parseAbsDir
, stripProperPrefix
) where
import qualified Path
import Path (Path, Rel, Abs, File, Dir, PathException)
import Polysemy
import Polysemy.Error
import Polysemy.Extra
parseRelFile :: Members '[Error PathException] r
=> FilePath
-> Sem r (Path Rel File)
parseRelFile :: FilePath -> Sem r (Path Rel File)
parseRelFile FilePath
x = (forall (m :: * -> *). MonadThrow m => m (Path Rel File))
-> Sem r (Path Rel File)
forall e (r :: [(* -> *) -> * -> *]) a.
(Exception e, Members '[Error e] r) =>
(forall (m :: * -> *). MonadThrow m => m a) -> Sem r a
irrefutableAbsorbThrow (FilePath -> m (Path Rel File)
forall (m :: * -> *). MonadThrow m => FilePath -> m (Path Rel File)
Path.parseRelFile FilePath
x)
parseAbsFile :: Members '[Error PathException] r
=> FilePath
-> Sem r (Path Abs File)
parseAbsFile :: FilePath -> Sem r (Path Abs File)
parseAbsFile FilePath
x = (forall (m :: * -> *). MonadThrow m => m (Path Abs File))
-> Sem r (Path Abs File)
forall e (r :: [(* -> *) -> * -> *]) a.
(Exception e, Members '[Error e] r) =>
(forall (m :: * -> *). MonadThrow m => m a) -> Sem r a
irrefutableAbsorbThrow (FilePath -> m (Path Abs File)
forall (m :: * -> *). MonadThrow m => FilePath -> m (Path Abs File)
Path.parseAbsFile FilePath
x)
parseRelDir :: Members '[Error PathException] r
=> FilePath
-> Sem r (Path Rel Dir)
parseRelDir :: FilePath -> Sem r (Path Rel Dir)
parseRelDir FilePath
x = (forall (m :: * -> *). MonadThrow m => m (Path Rel Dir))
-> Sem r (Path Rel Dir)
forall e (r :: [(* -> *) -> * -> *]) a.
(Exception e, Members '[Error e] r) =>
(forall (m :: * -> *). MonadThrow m => m a) -> Sem r a
irrefutableAbsorbThrow (FilePath -> m (Path Rel Dir)
forall (m :: * -> *). MonadThrow m => FilePath -> m (Path Rel Dir)
Path.parseRelDir FilePath
x)
parseAbsDir :: Members '[Error PathException] r
=> FilePath
-> Sem r (Path Abs Dir)
parseAbsDir :: FilePath -> Sem r (Path Abs Dir)
parseAbsDir FilePath
x = (forall (m :: * -> *). MonadThrow m => m (Path Abs Dir))
-> Sem r (Path Abs Dir)
forall e (r :: [(* -> *) -> * -> *]) a.
(Exception e, Members '[Error e] r) =>
(forall (m :: * -> *). MonadThrow m => m a) -> Sem r a
irrefutableAbsorbThrow (FilePath -> m (Path Abs Dir)
forall (m :: * -> *). MonadThrow m => FilePath -> m (Path Abs Dir)
Path.parseAbsDir FilePath
x)
stripProperPrefix :: Members '[Error PathException] r
=> Path b Dir
-> Path b t
-> Sem r (Path Rel t)
stripProperPrefix :: Path b Dir -> Path b t -> Sem r (Path Rel t)
stripProperPrefix Path b Dir
x Path b t
y = (forall (m :: * -> *). MonadThrow m => m (Path Rel t))
-> Sem r (Path Rel t)
forall e (r :: [(* -> *) -> * -> *]) a.
(Exception e, Members '[Error e] r) =>
(forall (m :: * -> *). MonadThrow m => m a) -> Sem r a
irrefutableAbsorbThrow (Path b Dir -> Path b t -> m (Path Rel t)
forall (m :: * -> *) b t.
MonadThrow m =>
Path b Dir -> Path b t -> m (Path Rel t)
Path.stripProperPrefix Path b Dir
x Path b t
y)