diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2018-02-03 11:26:52 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2018-02-03 11:26:52 +0100 |
commit | 61b9e74f5f14ee0af3eebb84764cbc93f119b730 (patch) | |
tree | b5c7618a8000d75dc08968cec4d77342b631d621 /src | |
parent | ae22b13a56c14af5274679ac1640e6a70d8a95b9 (diff) |
better hide for prelude path
Diffstat (limited to 'src')
-rw-r--r-- | src/LambdaCube/Compiler/DesugaredSource.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/LambdaCube/Compiler/DesugaredSource.hs b/src/LambdaCube/Compiler/DesugaredSource.hs index 2e967eff..ae2899bc 100644 --- a/src/LambdaCube/Compiler/DesugaredSource.hs +++ b/src/LambdaCube/Compiler/DesugaredSource.hs | |||
@@ -21,6 +21,7 @@ import qualified Data.ByteString.Char8 as BS | |||
21 | 21 | ||
22 | import Data.Binary | 22 | import Data.Binary |
23 | import GHC.Generics (Generic) | 23 | import GHC.Generics (Generic) |
24 | import qualified System.FilePath.Posix as FilePath | ||
24 | 25 | ||
25 | --import Data.Text (Text) | 26 | --import Data.Text (Text) |
26 | import Data.Monoid | 27 | import Data.Monoid |
@@ -36,6 +37,8 @@ import LambdaCube.Compiler.Utils | |||
36 | import LambdaCube.Compiler.DeBruijn | 37 | import LambdaCube.Compiler.DeBruijn |
37 | import LambdaCube.Compiler.Pretty --hiding (braces, parens) | 38 | import LambdaCube.Compiler.Pretty --hiding (braces, parens) |
38 | 39 | ||
40 | import Paths_lambdacube_compiler (getDataDir) | ||
41 | |||
39 | -------------------------------------------------------------------------------- simple name | 42 | -------------------------------------------------------------------------------- simple name |
40 | 43 | ||
41 | -- TODO: move to Text | 44 | -- TODO: move to Text |
@@ -99,7 +102,14 @@ fileContent fi = unsafePerformIO $ do | |||
99 | instance Eq FileInfo where (==) = (==) `on` fileId | 102 | instance Eq FileInfo where (==) = (==) `on` fileId |
100 | instance Ord FileInfo where compare = compare `on` fileId | 103 | instance Ord FileInfo where compare = compare `on` fileId |
101 | 104 | ||
102 | instance PShow FileInfo where pShow = text . filePath --(++ ".lc") . fileModule | 105 | instance PShow FileInfo where |
106 | pShow fi = let path = filePath fi | ||
107 | in text $ if isPrefixOf lcPreludePath path | ||
108 | then "<<installed-prelude-path>>" ++ drop (length lcPreludePath) path | ||
109 | else path | ||
110 | |||
111 | lcPreludePath :: String | ||
112 | lcPreludePath = unsafePerformIO $ (FilePath.</> "lc") <$> getDataDir | ||
103 | 113 | ||
104 | showPos :: FileInfo -> SPos -> Doc | 114 | showPos :: FileInfo -> SPos -> Doc |
105 | showPos n p = pShow n <> ":" <> pShow p | 115 | showPos n p = pShow n <> ":" <> pShow p |