File tree Expand file tree Collapse file tree 3 files changed +44
-9
lines changed Expand file tree Collapse file tree 3 files changed +44
-9
lines changed Original file line number Diff line number Diff line change 3131
3232 charAt :: Number -> String -> Maybe Char
3333
34- charCodeAt :: Number -> String -> Number
34+ charCodeAt :: Number -> String -> Maybe Number
3535
3636 drop :: Number -> String -> String
3737
104104
105105 split :: Regex -> String -> [String]
106106
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
3737 fromChar :: Char -> String
3838 fromChar = charString
3939
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
4648
4749 foreign import fromCharArray
4850 " function fromCharArray(a) {\
@@ -123,7 +125,7 @@ module Data.String
123125 \ };\
124126 \}" :: String -> String -> [String ]
125127
126- foreign import toCharArray
128+ foreign import toCharArray
127129 " function toCharArray(s) {\
128130 \ return s.split('');\
129131 \}" :: 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