Skip to content

Commit d234d55

Browse files
committed
update unionmount
1 parent f44b014 commit d234d55

4 files changed

Lines changed: 81 additions & 78 deletions

File tree

cabal.project

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,5 @@ packages: .
22

33
source-repository-package
44
type: git
5-
location: https://github.com/lucasvreis/lvar.git
6-
tag: b92b8c3d804b83c0b516f23f2b4486d119a24a50
7-
8-
source-repository-package
9-
type: git
10-
location: https://github.com/srid/unionmount.git
11-
tag: fb401ce6030e0f516ea105e1f5c400260b3ade33
5+
location: https://github.com/estradilua/unionmount-co-log.git
6+
tag: f9323877ab4d61205f38c772b08418a8d2d71b24

ondim-json/src/Ondim/Targets/Aeson/Instances.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ instance OndimNode AesonNode where
6767
_ -> Nothing
6868
children = \case
6969
(Object' o)
70-
| Just (Array' a) <- L.lookup "$children" o -> a
70+
| Just (Array' a) <- L.lookup "children" o -> a
7171
_ -> mempty
7272
attributes (Object' o) = mapMaybeM go $ M.toPairs o
7373
where

ondim.cabal

Lines changed: 48 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
cabal-version: 3.4
2-
name: ondim
3-
version: 0.1.0.0
4-
author: Lucas V. R.
5-
maintainer: @lucasvr:matrix.org
1+
cabal-version: 3.4
2+
name: ondim
3+
version: 0.1.0.0
4+
author: Lua V. R.
5+
maintainer: @luavr:matrix.org
66
extra-source-files: CHANGELOG.md
77

88
common common
9-
default-language: GHC2021
10-
ghc-options: -Wall
9+
default-language: GHC2021
10+
ghc-options: -Wall
1111
build-depends:
12-
, base >=4.14 && <5
13-
, relude
12+
base >=4.14 && <5,
13+
relude,
1414

1515
mixins:
1616
base hiding (Prelude),
1717
relude (Relude as Prelude),
18-
relude
18+
relude,
1919

2020
default-extensions:
2121
BlockArguments
@@ -28,8 +28,8 @@ common common
2828
ViewPatterns
2929

3030
library
31-
import: common
32-
hs-source-dirs: src
31+
import: common
32+
hs-source-dirs: src
3333
exposed-modules:
3434
Ondim
3535
Ondim.Advanced
@@ -46,15 +46,14 @@ library
4646
Ondim.Internal.Core
4747

4848
build-depends:
49-
, containers >=0.6.0 && <0.7
50-
, filepath
51-
, filepattern
52-
, monad-logger
53-
, mtl >=2.2.2 && <2.4
54-
, text
55-
, unionmount
56-
, unliftio-core
57-
, unordered-containers
49+
co-log-core,
50+
containers >=0.6.0 && <0.7,
51+
filepath,
52+
filepattern,
53+
mtl >=2.2.2 && <2.4,
54+
text,
55+
unionmount,
56+
unordered-containers,
5857

5958
-- library ondim-generic
6059
-- import: common
@@ -63,9 +62,7 @@ library
6362
-- build-depends:
6463
-- , multiwalk
6564
-- , ondim
66-
6765
-- exposed-modules: Ondim.Expansible.Generic
68-
6966
-- library ondim-th
7067
-- import: common
7168
-- visibility: public
@@ -75,48 +72,46 @@ library
7572
-- , optics-core
7673
-- , template-haskell
7774
-- , template-haskell-optics
78-
7975
-- exposed-modules: Ondim.Expansible.TH
8076
-- other-modules: Ondim.Expansible.Test
81-
8277
library ondim-whiskers
83-
import: common
84-
visibility: public
85-
hs-source-dirs: ondim-whiskers/src
78+
import: common
79+
visibility: public
80+
hs-source-dirs: ondim-whiskers/src
8681
build-depends:
87-
, megaparsec
88-
, ondim
82+
megaparsec,
83+
ondim,
8984

90-
other-modules: Ondim.Targets.Whiskers.Parser
85+
other-modules: Ondim.Targets.Whiskers.Parser
9186
exposed-modules:
9287
Ondim.Targets.Whiskers
9388
Ondim.Targets.Whiskers.Expansions
9489
Ondim.Targets.Whiskers.Instances
9590
Ondim.Targets.Whiskers.Load
9691

9792
library ondim-latex
98-
import: common
99-
visibility: public
100-
hs-source-dirs: ondim-latex/src
93+
import: common
94+
visibility: public
95+
hs-source-dirs: ondim-latex/src
10196
build-depends:
102-
, megaparsec
103-
, ondim
97+
megaparsec,
98+
ondim,
10499

105-
other-modules: Ondim.Targets.LaTeX.Parser
100+
other-modules: Ondim.Targets.LaTeX.Parser
106101
exposed-modules:
107102
Ondim.Targets.LaTeX
108103
Ondim.Targets.LaTeX.Expansions
109104
Ondim.Targets.LaTeX.Instances
110105
Ondim.Targets.LaTeX.Load
111106

112107
library ondim-json
113-
import: common
114-
visibility: public
115-
hs-source-dirs: ondim-json/src
108+
import: common
109+
visibility: public
110+
hs-source-dirs: ondim-json/src
116111
build-depends:
117-
, aeson
118-
, ondim:{ondim, ondim-whiskers}
119-
, scientific
112+
aeson,
113+
ondim:{ondim, ondim-whiskers},
114+
scientific,
120115

121116
exposed-modules:
122117
Ondim.Extra.BindJSON
@@ -125,17 +120,17 @@ library ondim-json
125120
Ondim.Targets.Aeson.Instances
126121

127122
library ondim-html
128-
import: common
129-
visibility: public
130-
hs-source-dirs: ondim-html/src
123+
import: common
124+
visibility: public
125+
hs-source-dirs: ondim-html/src
131126
build-depends:
132-
, conduit
133-
, containers
134-
, html-conduit >=1.3.2.1 && <1.4
135-
, lucid
136-
, ondim:{ondim, ondim-whiskers}
137-
, xml-conduit >=1.9.0 && <1.10
138-
, xml-types
127+
conduit,
128+
containers,
129+
html-conduit >=1.3.2.1 && <1.4,
130+
lucid,
131+
ondim:{ondim, ondim-whiskers},
132+
xml-conduit >=1.9.0 && <1.10,
133+
xml-types,
139134

140135
exposed-modules:
141136
Ondim.Targets.HTML

src/Ondim/Loading.hs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,39 @@ module Ondim.Loading
77
( loadTemplates,
88
loadTemplatesDynamic,
99
loadTemplatesEmbed,
10+
1011
-- * \"Advanced\" usage
12+
1113
--
14+
1215
-- | There are default 'LoadConfig's inside each target's respective
1316
-- modules, but you can also use the definitions below to customize them if
1417
-- you wish.
1518
LoadConfig (..),
1619
LoadFn,
1720
loadFnSimple,
18-
TemplateLoadingException (..)
21+
TemplateLoadingException (..),
1922
) where
2023

2124
import Control.Exception (throw)
22-
import Control.Monad.IO.Unlift (MonadUnliftIO)
23-
import Control.Monad.Logger (MonadLogger, runNoLoggingT)
2425
import Data.Map ((!))
2526
import Ondim
26-
import Ondim.Debug
27+
( NamespaceItem (TemplateData),
28+
OndimNode,
29+
OndimState (expansions),
30+
delete,
31+
insert,
32+
)
33+
import Ondim.Internal.Basic (fileSite)
2734
import Relude.Extra (minimumOn1, toPairs)
2835
import System.FilePath (splitDirectories, (</>))
2936
import System.FilePattern (FilePattern, matchMany)
3037
import System.UnionMount
38+
( Change,
39+
FileAction (Delete, Refresh),
40+
Logger,
41+
unionMount,
42+
)
3143

3244
-- | Some template loading (impure) exception.
3345
newtype TemplateLoadingException = TemplateLoadingException String
@@ -61,35 +73,36 @@ loadFnToUpdate fn fp name bs s =
6173

6274
-- | Configuration for loading templates of a specific type.
6375
data LoadConfig n = LoadConfig
64-
{ patterns :: [FilePattern],
65-
-- ^ Glob patterns to search for files.
76+
{ -- | Glob patterns to search for files.
77+
patterns :: [FilePattern],
78+
-- | Recipe to load the templates.
6679
loadFn :: LoadFn n,
67-
-- ^ Recipe to load the templates.
68-
initialState :: OndimState n
69-
-- ^ Initial state. You can use this to set some default expansions or
80+
-- | Initial state. You can use this to set some default expansions or
7081
-- templates that may be overshadowed by file templates.
82+
initialState :: OndimState n
7183
}
7284

7385
{- | Load templates from a list of directories in descending order of priority,
7486
and return the inital state and a watcher action that takes a handler to
7587
update the state when templates get updated on disk.
7688
-}
7789
loadTemplatesDynamic ::
78-
forall m n.
79-
(MonadLogger m, MonadIO m, MonadUnliftIO m) =>
90+
forall n.
8091
-- | Loading configurations
8192
[LoadConfig n] ->
8293
-- | Places to look for templates and their (optional) mount point,
8394
-- in descending order of priority.
8495
[(FilePath, Maybe FilePath)] ->
85-
m (OndimState n, (OndimState n -> m ()) -> m ())
86-
loadTemplatesDynamic cfgs places =
96+
-- | Logger
97+
Logger ->
98+
IO (OndimState n, (OndimState n -> IO ()) -> IO ())
99+
loadTemplatesDynamic cfgs places logger =
87100
let sources = fromList (zip (zip [1 ..] (fst <$> places)) places)
88101
cfgMap = fromList $ [(i, f) | (i, loadFn -> f) <- zip [1 ..] cfgs]
89102
patts = [(i, p) | (i, patterns -> ps) <- zip [1 ..] cfgs, p <- ps]
90103
exclude = []
91104
initial = foldMap' initialState cfgs
92-
handler :: Change (Int, FilePath) Int -> m (OndimState n -> OndimState n)
105+
handler :: Change (Int, FilePath) Int -> IO (OndimState n -> OndimState n)
93106
handler chg =
94107
appEndo . mconcat . coerce . join
95108
<$> forM (toPairs chg) \(i, chg') ->
@@ -101,11 +114,11 @@ loadTemplatesDynamic cfgs places =
101114
fp = dir </> file
102115
in readFileLBS fp <&> loadFnToUpdate (cfgMap ! i) fp name
103116
Delete -> pure \s -> s {expansions = delete name (expansions s)} <> initial
104-
in unionMount sources patts exclude initial handler
117+
in unionMount sources patts exclude initial logger handler
105118

106119
-- | Load templates from a list of directories in descending order of priority.
107-
loadTemplates :: [LoadConfig n] -> [(FilePath, Maybe FilePath)] -> IO (OndimState n)
108-
loadTemplates cfgs dirs = fst <$> runNoLoggingT (loadTemplatesDynamic cfgs dirs)
120+
loadTemplates :: [LoadConfig n] -> [(FilePath, Maybe FilePath)] -> Logger -> IO (OndimState n)
121+
loadTemplates cfgs dirs logger = fst <$> loadTemplatesDynamic cfgs dirs logger
109122

110123
{- | Load templates in pure code from a list of filepaths and bytestrings. Meant
111124
to be used with the @file-embed@ package.

0 commit comments

Comments
 (0)