File tree 3 files changed +44
-9
lines changed
3 files changed +44
-9
lines changed Original file line number Diff line number Diff line change 31
31
32
32
charAt :: Number -> String -> Maybe Char
33
33
34
- charCodeAt :: Number -> String -> Number
34
+ charCodeAt :: Number -> String -> Maybe Number
35
35
36
36
drop :: Number -> String -> String
37
37
104
104
105
105
split :: Regex -> String -> [String]
106
106
107
- test :: Regex -> String -> Boolean
107
+ test :: Regex -> String -> Boolean
108
+
109
+
110
+ ## Module Data.String.Unsafe
111
+
112
+ ### Values
113
+
114
+ charAt :: Number -> String -> Char
115
+
116
+ charCodeAt :: Number -> String -> Number
Original file line number Diff line number Diff line change @@ -37,12 +37,14 @@ module Data.String
37
37
fromChar :: Char -> String
38
38
fromChar = charString
39
39
40
- foreign import charCodeAt
41
- " function charCodeAt(i) {\
42
- \ return function(s) {\
43
- \ return s.charCodeAt(i); \
44
- \ };\
45
- \}" :: Number -> String -> Number
40
+ foreign import _charCodeAt
41
+ " function _charCodeAt(i, s, Just, Nothing) {\
42
+ \ if (i < 0 || i >= s.length) return Nothing;\
43
+ \ else return Just(s.charCodeAt(i));\
44
+ \}" :: forall a. Fn4 Number String (a -> Maybe a ) (Maybe a ) (Maybe Number )
45
+
46
+ charCodeAt :: Number -> String -> Maybe Number
47
+ charCodeAt n s = runFn4 _charCodeAt n s Just Nothing
46
48
47
49
foreign import fromCharArray
48
50
" function fromCharArray(a) {\
@@ -123,7 +125,7 @@ module Data.String
123
125
\ };\
124
126
\}" :: String -> String -> [String ]
125
127
126
- foreign import toCharArray
128
+ foreign import toCharArray
127
129
" function toCharArray(s) {\
128
130
\ return s.split('');\
129
131
\}" :: String -> [Char ]
Original file line number Diff line number Diff line change
1
+ module Data.String.Unsafe
2
+ ( charAt
3
+ , charCodeAt
4
+ ) where
5
+
6
+ import Data.Char
7
+
8
+ foreign import charCodeAt
9
+ " " "
10
+ function charCodeAt(i) {
11
+ return function(s) {
12
+ return s.charCodeAt(i);
13
+ };
14
+ }
15
+ " " " :: Number -> String -> Number
16
+
17
+ foreign import charAt
18
+ " " "
19
+ function charAt(i) {
20
+ return function(s) {
21
+ return s.charAt(i);
22
+ };
23
+ }
24
+ " " " :: Number -> String -> Char
You can’t perform that action at this time.
0 commit comments