Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all usages of String with Text #168

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Unpack the Data.Text strings in Rzk JS
  • Loading branch information
aabounegm committed Jan 9, 2024
commit 2bf8742a180d51ab15fdc54e9a3f7610b298eaa6
5 changes: 3 additions & 2 deletions rzk-js/Main.hs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import qualified GHCJS.Foreign.Callback as GHCJS
import GHCJS.Marshal (fromJSVal, toJSVal)
import GHCJS.Prim (JSVal)
import Data.JSString(JSString, pack)
import qualified Data.Text as T
import JavaScript.Object
import JavaScript.Object.Internal (Object (..), create)
import qualified Rzk.Main as Rzk
@@ -23,8 +24,8 @@ main = do
input <- maybe (Left "Could not turn JSRef to a String") Right <$> fromJSVal rawInput

case Rzk.typecheckString =<< input of
Left err -> setStringProp "status" "error" o >> setStringProp "result" (pack err) o
Right ok -> setStringProp "status" "ok" o >> setStringProp "result" (pack ok) o
Left err -> setStringProp "status" "error" o >> setStringProp "result" (pack (T.unpack err)) o
Right ok -> setStringProp "status" "ok" o >> setStringProp "result" (pack (T.unpack ok)) o

set_rzk_typecheck_callback callback

2 changes: 1 addition & 1 deletion rzk-js/rzk-js.cabal
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ executable rzk-js
main-is: Main.hs
ghcjs-options:
-dedupe
build-depends: base, rzk
build-depends: base, rzk, text >=1.2.3.1
if impl(ghcjs)
build-depends:
ghcjs-base, ghcjs-prim
Loading