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.6/conduit-extra-text-jsstring.patch
1 views
1
diff --git a/Data/Conduit/Attoparsec.hs b/Data/Conduit/Attoparsec.hs
2
index bd889f8..a620675 100644
3
--- a/Data/Conduit/Attoparsec.hs
4
+++ b/Data/Conduit/Attoparsec.hs
5
@@ -1,4 +1,5 @@
6
{-# LANGUAGE BangPatterns #-}
7
+{-# LANGUAGE CPP #-}
8
{-# LANGUAGE DeriveDataTypeable #-}
9
{-# LANGUAGE FlexibleContexts #-}
10
{-# LANGUAGE RankNTypes #-}
11
@@ -33,6 +34,9 @@ import qualified Data.Text as T
12
import qualified Data.Text.Internal as TI
13
import Data.Typeable (Typeable)
14
import Prelude hiding (lines)
15
+#ifdef __GHCJS__
16
+import qualified Data.JSString.Raw as JSS
17
+#endif
18
19
import qualified Data.Attoparsec.ByteString
20
import qualified Data.Attoparsec.Text
21
@@ -105,8 +109,13 @@ instance AttoparsecInput T.Text where
22
f (Position l c o) ch
23
| ch == '\n' = Position (l + 1) 0 (o + 1)
24
| otherwise = Position l (c + 1) (o + 1)
25
+#ifndef __GHCJS__
26
stripFromEnd (TI.Text arr1 off1 len1) (TI.Text _ _ len2) =
27
TI.text arr1 off1 (len1 - len2)
28
+#else
29
+ stripFromEnd (TI.Text str1) (TI.Text str2) =
30
+ TI.Text $ JSS.rawDropEnd (JSS.rawLength str1 - JSS.rawLength str2) str1
31
+#endif
32
33
-- | Convert an Attoparsec 'A.Parser' into a 'Sink'. The parser will
34
-- be streamed bytes until it returns 'A.Done' or 'A.Fail'.
35
diff --git a/conduit-extra.cabal b/conduit-extra.cabal
36
index f6dfe7a..b5b2515 100644
37
--- a/conduit-extra.cabal
38
+++ b/conduit-extra.cabal
39
@@ -58,6 +58,9 @@ Library
40
, unliftio-core
41
, typed-process >= 0.2
42
43
+ if impl(ghcjs)
44
+ Build-depends: ghcjs-base
45
+
46
ghc-options: -Wall
47
48
test-suite test
49
50