Skip to content

Commit 3657090

Browse files
committed
Switch some naming from eve ext -> state
1 parent 8b06dc3 commit 3657090

File tree

6 files changed

+25
-26
lines changed

6 files changed

+25
-26
lines changed

rasa-ext-cmd/src/Rasa/Ext/Cmd.hs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{-# LANGUAGE TemplateHaskell #-}
2-
31
module Rasa.Ext.Cmd
42
( addCmd
53
, runCmd
@@ -26,12 +24,12 @@ instance Default Cmd where
2624
-- TODO try switching to T.Text -> (T.Text -> a) -> App ()
2725
addCmd :: String -> (String -> App ()) -> App ()
2826
addCmd alias mkEvent =
29-
ext %= add
27+
stateLens %= add
3028
where add (Cmd commands) = Cmd $ commands & at alias ?~ mkEvent
3129

3230
runCmd :: String -> String -> App ()
3331
runCmd alias args = do
34-
Cmd commands <- use ext
32+
Cmd commands <- use stateLens
3533
let mCmd = commands^.at alias
3634
case mCmd of
3735
Just cmd -> cmd args

rasa-ext-slate/src/Rasa/Ext/Slate/Internal/State.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ initUi :: App V.Vty
1616
initUi = do
1717
cfg <- liftIO V.standardIOConfig
1818
v <- liftIO $ V.mkVty cfg
19-
ext .= Just (Slate v)
19+
stateLens .= Just (Slate v)
2020
return v
2121

2222
-- | Gets vty by checking if it has been initialized yet, if not it runs the initialization.
2323
getVty :: App V.Vty
2424
getVty = do
25-
v <- use ext
25+
v <- use stateLens
2626
case v of
2727
Just (Slate v') -> return v'
2828
Nothing -> initUi

rasa-ext-views/src/Rasa/Ext/Views/Internal/Views.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,18 @@ instance Default Views where
126126
-- | Gets the stored views
127127
getViews :: App (Maybe Window)
128128
getViews = do
129-
Views mWin <- use ext
129+
Views mWin <- use stateLens
130130
return mWin
131131

132132
-- | Sets the stored views
133133
setViews :: Maybe Window -> App ()
134-
setViews v = ext .= Views v
134+
setViews v = stateLens .= Views v
135135

136136
-- | Run function over stored windows
137137
overWindows :: (Window -> Window) -> App ()
138138
overWindows f = do
139-
Views mWin <- use ext
140-
ext .= (Views $ fmap f mWin)
139+
Views mWin <- use stateLens
140+
stateLens .= (Views $ fmap f mWin)
141141

142142
-- | Flip all Horizontal splits to Vertical ones and vice versa.
143143
rotate :: Window -> Window

rasa/src/Rasa/Internal/BufActions.hs

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ getBufRef :: BufAction BufRef
8585
getBufRef = use ref
8686

8787
-- | Retrieve some buffer extension state
88-
getBufExt :: (Typeable ext, Show ext, Default ext) => BufAction ext
89-
getBufExt = use ext
88+
getBufExt :: (Typeable s, Show s, Default s) => BufAction s
89+
getBufExt = use stateLens
9090

9191
-- | Set some buffer extension state
92-
setBufExt :: (Typeable ext, Show ext, Default ext) => ext -> BufAction ()
93-
setBufExt newExt = ext .= newExt
92+
setBufExt :: (Typeable s, Show s, Default s) => s -> BufAction ()
93+
setBufExt newExt = stateLens .= newExt
9494

9595
-- | Set some buffer extension state
96-
overBufExt :: (Typeable ext, Show ext, Default ext) => (ext -> ext) -> BufAction ()
97-
overBufExt f = ext %= f
96+
overBufExt :: (Typeable s, Show s, Default s) => (s -> s) -> BufAction ()
97+
overBufExt f = stateLens %= f
9898

9999
-- -- | This lifts up an 'Action' to be run inside a 'BufAction'
100100
-- liftAction :: App r -> BufAction r

rasa/src/Rasa/Internal/Buffer.hs

+9-9
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ instance Default NextBufId where
4848
def = NextBufId 0
4949

5050
makeLenses ''NextBufId
51-
nextBufId :: HasExts s => Lens' s Int
52-
nextBufId = ext.nextBufId'
51+
nextBufId :: HasStates s => Lens' s Int
52+
nextBufId = stateLens.nextBufId'
5353

5454
-- | A buffer, holds the text in the buffer and any extension states that are set on the buffer.
5555
data Buffer = Buffer
5656
{ _text' :: Y.YiString
57-
, _bufExts' :: Exts
57+
, _bufStates' :: States
5858
, _ref :: BufRef
5959
}
6060
makeLenses ''Buffer
6161

62-
instance HasExts Buffer where
63-
exts = bufExts'
62+
instance HasStates Buffer where
63+
states = bufStates'
6464

6565
instance HasEvents Buffer where
6666

@@ -79,7 +79,7 @@ instance Show Buffer where
7979
show b = "text:" ++ (Y.toString . Y.take 30 $ (b^.text)) ++ "...,\n"
8080
++ "exts: " ++ extText ++ "}>\n"
8181
where
82-
extText = intercalate "\n" $ show <$> b^.exts.to M.toList
82+
extText = intercalate "\n" $ show <$> b^.states.to M.toList
8383

8484
type BufAction a = Action Buffer a
8585

@@ -92,14 +92,14 @@ instance Default Buffers where
9292
def = Buffers mempty
9393

9494
-- | A lens over the map of available buffers
95-
buffers :: HasExts s => Lens' s (IM.IntMap Buffer)
96-
buffers = ext.buffers'
95+
buffers :: HasStates s => Lens' s (IM.IntMap Buffer)
96+
buffers = stateLens.buffers'
9797

9898
-- | Creates a new buffer from the given text.
9999
mkBuffer :: Y.YiString -> BufRef -> Buffer
100100
mkBuffer txt bRef =
101101
Buffer
102102
{ _text' = txt
103-
, _bufExts' = mempty
103+
, _bufStates' = mempty
104104
, _ref = bRef
105105
}

stack.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ packages:
1818
- ./rasa-ext-vim
1919
- ./rasa-example-config
2020
- ./text-lens
21+
- ../eve
2122

2223
extra-deps:
23-
- eve-0.1.0
24+
# - eve-0.1.0
2425
- vty-5.14
2526
- recursion-schemes-5.0.1
2627

0 commit comments

Comments
 (0)