Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
reflex-frp
GitHub Repository: reflex-frp/reflex-platform
Path: blob/develop/haskell-overlays/text-jsstring-8.10/doube-conversion-Add-test-jsstring.patch
1 views
1
From 0f9ddde468687d25fa6c4c9accb02a034bc2f9c3 Mon Sep 17 00:00:00 2001
2
From: Luigy Leon <[email protected]>
3
Date: Thu, 1 Dec 2016 12:43:59 -0500
4
Subject: [PATCH] Add text jsstring support for ghcjs.
5
6
---
7
Data/Double/Conversion/Text.hs | 17 +++++++++++++++--
8
double-conversion.cabal | 4 ++++
9
2 files changed, 19 insertions(+), 2 deletions(-)
10
11
diff --git a/Data/Double/Conversion/Text.hs b/Data/Double/Conversion/Text.hs
12
index 2e89705..3b315a7 100644
13
--- a/Data/Double/Conversion/Text.hs
14
+++ b/Data/Double/Conversion/Text.hs
15
@@ -1,4 +1,4 @@
16
-{-# LANGUAGE CPP, MagicHash, Rank2Types #-}
17
+{-# LANGUAGE CPP, MagicHash, Rank2Types, ForeignFunctionInterface, UnliftedFFITypes #-}
18
19
-- |
20
-- Module : Data.Double.Conversion.Text
21
@@ -33,7 +33,12 @@ import Control.Monad.ST (runST)
22
import Data.Double.Conversion.FFI
23
import Data.Text.Internal (Text(Text))
24
import Foreign.C.Types (CDouble, CInt)
25
-import GHC.Prim (MutableByteArray#)
26
+#ifndef __GHCJS__
27
+import GHC.Prim (MutableByteArray#, ByteArray#)
28
+#else
29
+import GHC.Prim (MutableByteArray#, Int#, ByteArray#)
30
+import Data.JSString
31
+#endif
32
import qualified Data.Text.Array as A
33
34
-- | Compute a representation in exponential format with the requested
35
@@ -81,4 +86,12 @@ convert func len act val = runST go
36
fail $ "Data.Double.Conversion.Text." ++ func ++
37
": conversion failed (invalid precision requested)"
38
frozen <- A.unsafeFreeze buf
39
+#ifndef __GHCJS__
40
return $ Text frozen 0 (fromIntegral size)
41
+#else
42
+ return $ Text $ js_toString (A.aBA frozen) 0# (fromIntegral size)
43
+
44
+foreign import javascript unsafe
45
+ "h$textToString"
46
+ js_toString :: ByteArray# -> Int# -> Int -> JSString
47
+#endif
48
diff --git a/double-conversion.cabal b/double-conversion.cabal
49
index d177d3f..5f0527f 100644
50
--- a/double-conversion.cabal
51
+++ b/double-conversion.cabal
52
@@ -90,6 +90,10 @@ library
53
ghc-prim,
54
text >= 0.11.0.8
55
56
+ if impl(ghcjs)
57
+ build-depends:
58
+ ghcjs-base
59
+
60
if flag(developer)
61
ghc-options: -Werror
62
ghc-prof-options: -auto-all
63
--
64
2.31.1
65
66