Readd TH constructors
This commit is contained in:
parent
bd71947b2a
commit
8c1bd139c0
@ -21,6 +21,7 @@ library
|
|||||||
, exceptions
|
, exceptions
|
||||||
, deepseq
|
, deepseq
|
||||||
, word8
|
, word8
|
||||||
|
, template-haskell
|
||||||
|
|
||||||
test-suite test
|
test-suite test
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
|
40
src/HPath.hs
40
src/HPath.hs
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE DeriveDataTypeable #-}
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
{-# LANGUAGE EmptyDataDecls #-}
|
{-# LANGUAGE EmptyDataDecls #-}
|
||||||
{-# LANGUAGE PatternSynonyms #-}
|
{-# LANGUAGE PatternSynonyms #-}
|
||||||
@ -32,6 +33,10 @@ module HPath
|
|||||||
,parseAbs
|
,parseAbs
|
||||||
,parseFn
|
,parseFn
|
||||||
,parseRel
|
,parseRel
|
||||||
|
-- * Path Constructors
|
||||||
|
,mkAbs
|
||||||
|
,mkFn
|
||||||
|
,mkRel
|
||||||
-- * Path Conversion
|
-- * Path Conversion
|
||||||
,canonicalizePath
|
,canonicalizePath
|
||||||
,fromAbs
|
,fromAbs
|
||||||
@ -93,6 +98,8 @@ import Foreign.C.String
|
|||||||
import Foreign.Marshal.Alloc(allocaBytes)
|
import Foreign.Marshal.Alloc(allocaBytes)
|
||||||
import HPath.Foreign
|
import HPath.Foreign
|
||||||
import HPath.Internal
|
import HPath.Internal
|
||||||
|
import Language.Haskell.TH
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Types
|
-- Types
|
||||||
@ -167,6 +174,39 @@ parseFn filepath =
|
|||||||
else throwM (InvalidFn filepath)
|
else throwM (InvalidFn filepath)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- Constructors
|
||||||
|
|
||||||
|
-- | Make a 'Path Abs TPS'.
|
||||||
|
--
|
||||||
|
-- Remember: due to the nature of absolute paths this (e.g. @\/home\/foo@)
|
||||||
|
-- may compile on your platform, but it may not compile on another
|
||||||
|
-- platform (Windows).
|
||||||
|
mkAbs :: ByteString -> Q Exp
|
||||||
|
mkAbs s =
|
||||||
|
case parseAbs s of
|
||||||
|
Left err -> error (show err)
|
||||||
|
Right (MkPath str) ->
|
||||||
|
[|MkPath $(return (LitE (StringL (show str)))) :: Path Abs|]
|
||||||
|
|
||||||
|
-- | Make a 'Path Rel TPS'.
|
||||||
|
mkRel :: ByteString -> Q Exp
|
||||||
|
mkRel s =
|
||||||
|
case parseRel s of
|
||||||
|
Left err -> error (show err)
|
||||||
|
Right (MkPath str) ->
|
||||||
|
[|MkPath $(return (LitE (StringL (show str)))) :: Path Rel|]
|
||||||
|
|
||||||
|
-- | Make a 'Path Rel TPS'.
|
||||||
|
mkFn :: ByteString -> Q Exp
|
||||||
|
mkFn s =
|
||||||
|
case parseFn s of
|
||||||
|
Left err -> error (show err)
|
||||||
|
Right (MkPath str) ->
|
||||||
|
[|MkPath $(return (LitE (StringL (show str)))) :: Path Fn|]
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Path Conversion
|
-- Path Conversion
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user