module UrlPath
( UrlReader (..)
, Url (..)
, module UrlPath.Types ) where
import UrlPath.Types
import Data.String
import Data.Monoid
import Control.Applicative
import Control.Monad
import Control.Monad.Trans
import Control.Monad.Reader.Class
class ( IsString plain
, Monoid plain
, MonadReader plain m
) => Url plain (m :: * -> *) where
url :: UrlString plain
-> m plain
plainUrl :: plain
-> m plain
class Url plain m => UrlReader plain (m :: * -> *) where
type Result m :: * -> *
runUrlReader :: Url plain m =>
m b
-> plain
-> Result m b
instance ( Monad m
, Monoid plain
, IsString plain ) => Url plain (RelativeUrlT plain m) where
url = RelativeUrlT . const . return . expandRelative
plainUrl x = RelativeUrlT $ const $ return $ expandRelative $ UrlString x []
instance ( Monad m
, Monoid plain
, IsString plain ) => UrlReader plain (RelativeUrlT plain m) where
type Result (RelativeUrlT plain m) = m
runUrlReader = runRelativeUrlT
instance ( Monad m
, Monoid plain
, IsString plain ) => Url plain (GroundedUrlT plain m) where
url = GroundedUrlT . const . return . expandGrounded
plainUrl x = GroundedUrlT $ const $ return $ expandGrounded $ UrlString x []
instance ( Monad m
, Monoid plain
, IsString plain ) => UrlReader plain (GroundedUrlT plain m) where
type Result (GroundedUrlT plain m) = m
runUrlReader = runGroundedUrlT
instance ( Monad m
, Monoid plain
, IsString plain ) => Url plain (AbsoluteUrlT plain m) where
url = expandAbsolute
plainUrl x = expandAbsolute $ UrlString x []
instance ( Monad m
, Monoid plain
, IsString plain ) => UrlReader plain (AbsoluteUrlT plain m) where
type Result (AbsoluteUrlT plain m) = m
runUrlReader = runAbsoluteUrlT