Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 7dec4bb

Browse files
authored
Merge pull request #28 from garyb/tweaks
Fix shadow warnings, use newtype deriving
2 parents 6807e71 + 1ccc677 commit 7dec4bb

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/ECharts/Monad.purs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,11 @@ newtype DSLMonad (i ∷ # !) a = DSL (Writer (Array (Tuple String Foreign)) a)
2626
unDSL i a. DSLMonad i a Writer (Array (Tuple String Foreign)) a
2727
unDSL (DSL m) = m
2828

29-
instance functorDSLFunctor (DSLMonad i) where
30-
map f (DSL o) = DSL $ map f o
31-
32-
instance applyDSLApply (DSLMonad i) where
33-
apply (DSL f) (DSL o) = DSL $ apply f o
34-
35-
instance applicativeDSLApplicative (DSLMonad i) where
36-
pure = DSL <<< pure
37-
38-
instance bindDSLBind (DSLMonad i) where
39-
bind (DSL o) f = DSL $ o >>= unDSL <<< f
40-
41-
instance monadDSLMonad (DSLMonad i)
29+
derive newtype instance functorDSLFunctor (DSLMonad i)
30+
derive newtype instance applyDSLApply (DSLMonad i)
31+
derive newtype instance applicativeDSLApplicative (DSLMonad i)
32+
derive newtype instance bindDSLBind (DSLMonad i)
33+
derive newtype instance monadDSLMonad (DSLMonad i)
4234

4335
type DSL i = DSLMonad i Unit
4436

@@ -50,15 +42,15 @@ get k (DSL cs) =
5042
F.foldl (foldFn k) Nothing $ execWriter cs
5143
where
5244
foldFn String Maybe Foreign Tuple String Foreign Maybe Foreign
53-
foldFn k Nothing (Tuple kk f) | k == kk = Just f
45+
foldFn k' Nothing (Tuple kk f) | k' == kk = Just f
5446
foldFn _ a _ = a
5547

5648
lastWithKeys i f. F.Foldable f f String DSL i Maybe Foreign
5749
lastWithKeys ks (DSL cs) =
5850
F.foldl (foldFn ks) Nothing $ Arr.reverse $ execWriter cs
5951
where
6052
foldFn f String Maybe Foreign Tuple String Foreign Maybe Foreign
61-
foldFn ks Nothing (Tuple kk f) | F.elem kk ks = Just f
53+
foldFn ks' Nothing (Tuple kk f) | F.elem kk ks' = Just f
6254
foldFn _ a _ = a
6355

6456
applyOnePair Tuple String Foreign Foreign Foreign

0 commit comments

Comments
 (0)