Skip to content

Commit af218e8

Browse files
committed
Text -> MisoString
1 parent 844cb43 commit af218e8

25 files changed

+140
-205
lines changed

ghcjs/currency-converter/app.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ common pkg
2626

2727
other-modules:
2828
App.Misc
29-
App.Prelude
3029
App.Types
3130
App.Widgets.Assets
3231
App.Widgets.Cell

ghcjs/currency-converter/src/App/Misc.hs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ module App.Misc
2121
)
2222
where
2323

24-
import App.Prelude
2524
import App.Types
2625
import qualified Data.Generics as Syb
27-
import Functora.Money
26+
import Functora.Miso.Prelude
27+
import Functora.Money hiding (Text)
2828
import qualified Language.Javascript.JSaddle as JS
2929
import qualified Material.Snackbar as Snackbar
30-
import Miso hiding (URI, view)
3130
import qualified Prelude
3231

3332
getConverterAmountOptic ::
@@ -61,7 +60,7 @@ onKeyDownAction uid (KeyCode code) =
6160
let enterOrEscape = [13, 27] :: [Int]
6261
when (code `elem` enterOrEscape)
6362
. void
64-
. JS.eval @Text
63+
. JS.eval @MisoString
6564
$ "document.getElementById('"
6665
<> htmlUid uid
6766
<> "').getElementsByTagName('input')[0].blur();"
@@ -70,13 +69,14 @@ onKeyDownAction uid (KeyCode code) =
7069

7170
copyIntoClipboard :: (Show a, Data a) => Model -> a -> JSM ()
7271
copyIntoClipboard st x = do
73-
let txt = inspectMiso x
72+
let txt = inspect x
7473
unless (txt == mempty) $ do
75-
clip <- JS.global JS.! ("navigator" :: Text) JS.! ("clipboard" :: Text)
76-
prom <- clip ^. JS.js1 ("writeText" :: Text) txt
77-
success <- JS.function $ \_ _ _ -> textPopup @Text st "Copied!"
78-
failure <- JS.function $ \_ _ _ -> textPopup @Text st "Failed to copy!"
79-
void $ prom ^. JS.js2 ("then" :: Text) success failure
74+
clip <-
75+
JS.global JS.! ("navigator" :: MisoString) JS.! ("clipboard" :: MisoString)
76+
prom <- clip ^. JS.js1 ("writeText" :: MisoString) txt
77+
success <- JS.function $ \_ _ _ -> textPopup @MisoString st "Copied!"
78+
failure <- JS.function $ \_ _ _ -> textPopup @MisoString st "Failed to copy!"
79+
void $ prom ^. JS.js2 ("then" :: MisoString) success failure
8080

8181
copyIntoClipboardAction :: (Show a, Data a) => Model -> a -> Action
8282
copyIntoClipboardAction st x =
@@ -95,7 +95,7 @@ textPopup st x =
9595
)
9696
where
9797
msg =
98-
inspectMiso x
98+
inspect x
9999
& Snackbar.message
100100
& Snackbar.setActionIcon (Just (Snackbar.icon "close"))
101101
& Snackbar.setOnActionIconClick textPopupClosed
@@ -107,7 +107,7 @@ textPopupPure x st =
107107
%~ (Snackbar.addMessage msg . Snackbar.clearQueue)
108108
where
109109
msg =
110-
inspectMiso x
110+
inspect x
111111
& Snackbar.message
112112
& Snackbar.setActionIcon (Just (Snackbar.icon "close"))
113113
& Snackbar.setOnActionIconClick textPopupClosed
@@ -143,7 +143,7 @@ drainTChan chan = do
143143
verifyUid :: Uid -> JSM ()
144144
verifyUid uid =
145145
when (nullUid uid)
146-
$ consoleLog "UNEXPECTED NULL UID"
146+
$ consoleLog @MisoString "UNEXPECTED NULL UID"
147147

148148
duplicateAt ::
149149
forall a.
@@ -154,14 +154,14 @@ duplicateAt ::
154154
Action
155155
duplicateAt optic idx =
156156
PushUpdate $ do
157-
duplicator <- newUniqueDuplicator @Text
157+
duplicator <- newUniqueDuplicator @MisoString
158158
let updater loc el =
159159
if loc == idx
160160
then [el, closed $ duplicator el]
161161
else [el]
162162
pure
163163
. ChanItem 0
164-
$ (textPopupPure $ "Duplicated #" <> inspect @Text (idx + 1) <> "!")
164+
$ (textPopupPure @MisoString $ "Duplicated #" <> inspect (idx + 1) <> "!")
165165
. (& cloneTraversal optic %~ ((>>= uncurry updater) . zip [0 ..]))
166166
where
167167
closed :: a -> a
@@ -179,23 +179,23 @@ removeAt optic idx =
179179
else [el]
180180
pure
181181
. ChanItem 0
182-
$ (textPopupPure $ "Removed #" <> inspect @Text (idx + 1) <> "!")
182+
$ (textPopupPure @MisoString $ "Removed #" <> inspect (idx + 1) <> "!")
183183
. (& cloneTraversal optic %~ ((>>= uncurry updater) . zip [0 ..]))
184184

185185
moveUp :: ATraversal' Model [a] -> Int -> Action
186186
moveUp optic idx =
187187
PushUpdate
188188
. pure
189189
. ChanItem 0
190-
$ (textPopupPure $ "Moved #" <> inspect @Text (idx + 1) <> " up!")
190+
$ (textPopupPure @MisoString $ "Moved #" <> inspect (idx + 1) <> " up!")
191191
. (& cloneTraversal optic %~ swapAt (idx - 1) idx)
192192

193193
moveDown :: ATraversal' Model [a] -> Int -> Action
194194
moveDown optic idx =
195195
PushUpdate
196196
. pure
197197
. ChanItem 0
198-
$ (textPopupPure $ "Moved #" <> inspect @Text (idx + 1) <> " down!")
198+
$ (textPopupPure @MisoString $ "Moved #" <> inspect (idx + 1) <> " down!")
199199
. (& cloneTraversal optic %~ swapAt idx (idx + 1))
200200

201201
swapAt :: Int -> Int -> [a] -> [a]
@@ -222,7 +222,7 @@ newAssetAction optic =
222222
item <- newAsset "Price" 0 cur
223223
pure
224224
. ChanItem 0
225-
$ (textPopupPure @Text "Added asset!")
225+
$ (textPopupPure @MisoString "Added asset!")
226226
. (& cloneTraversal optic %~ (<> [item]))
227227

228228
newFieldPairAction ::
@@ -232,7 +232,7 @@ newFieldPairAction optic =
232232
item <- newFieldPair mempty $ DynamicFieldText mempty
233233
pure
234234
. ChanItem 0
235-
$ (textPopupPure @Text "Added note!")
235+
$ (textPopupPure @MisoString "Added note!")
236236
. (& cloneTraversal optic %~ (<> [item]))
237237

238238
newPaymentMethodAction :: ATraversal' Model [PaymentMethod Unique] -> Action
@@ -242,5 +242,5 @@ newPaymentMethodAction optic =
242242
item <- newPaymentMethod cur $ Just mempty
243243
pure
244244
. ChanItem 0
245-
$ (textPopupPure @Text "Added payment!")
245+
$ (textPopupPure @MisoString "Added payment!")
246246
. (& cloneTraversal optic %~ (<> [item]))

ghcjs/currency-converter/src/App/Prelude.hs

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)