1
1
module React.Hook
2
2
( Hook
3
+ , HookInput
4
+ , hookInput
3
5
4
6
, useState
5
7
, useStateLazy
@@ -8,8 +10,6 @@ module React.Hook
8
10
, SetState
9
11
10
12
, useEffect
11
- , effectInput
12
- , EffectInput
13
13
14
14
, useContext
15
15
, Context
@@ -20,12 +20,8 @@ module React.Hook
20
20
, Dispatch
21
21
22
22
, useCallback
23
- , callbackInput
24
- , CallbackInput
25
23
26
24
, useMemo
27
- , memoInput
28
- , MemoInput
29
25
30
26
, useRef
31
27
, getRef
@@ -101,19 +97,14 @@ foreign import useState_
101
97
useEffect
102
98
:: forall a
103
99
. Effect (Effect a )
104
- -> Maybe (Array EffectInput )
100
+ -> Maybe (Array HookInput )
105
101
-> Hook Unit
106
102
useEffect k = runFn2 useEffect_ k <<< Nullable .toNullable
107
103
108
- effectInput :: forall a . a -> EffectInput
109
- effectInput = unsafeCoerce
110
-
111
- foreign import data EffectInput :: Type
112
-
113
104
foreign import useEffect_
114
105
:: forall a
115
106
. Fn2 (Effect (Effect a ))
116
- (Nullable (Array EffectInput ))
107
+ (Nullable (Array HookInput ))
117
108
(Hook Unit )
118
109
119
110
useContext :: forall a . Context a -> Hook a
@@ -171,37 +162,27 @@ foreign import useReducerLazy_
171
162
useCallback
172
163
:: forall a b
173
164
. (a -> b )
174
- -> Maybe (Array CallbackInput )
165
+ -> Maybe (Array HookInput )
175
166
-> Hook (a -> b )
176
167
useCallback k = runFn2 useCallback_ k <<< Nullable .toNullable
177
168
178
- callbackInput :: forall a . a -> CallbackInput
179
- callbackInput = unsafeCoerce
180
-
181
- foreign import data CallbackInput :: Type
182
-
183
169
foreign import useCallback_
184
170
:: forall a b
185
171
. Fn2 (a -> b )
186
- (Nullable (Array CallbackInput ))
172
+ (Nullable (Array HookInput ))
187
173
(Hook (a -> b ))
188
174
189
175
useMemo
190
176
:: forall a b
191
177
. (Unit -> a -> b )
192
- -> Maybe (Array MemoInput )
178
+ -> Maybe (Array HookInput )
193
179
-> Hook (a -> b )
194
180
useMemo k = runFn2 useMemo_ k <<< Nullable .toNullable
195
181
196
- memoInput :: forall a . a -> MemoInput
197
- memoInput = unsafeCoerce
198
-
199
- foreign import data MemoInput :: Type
200
-
201
182
foreign import useMemo_
202
183
:: forall a b
203
184
. Fn2 (Unit -> a -> b )
204
- (Nullable (Array MemoInput ))
185
+ (Nullable (Array HookInput ))
205
186
(Hook (a -> b ))
206
187
207
188
useRef :: forall a . Maybe a -> Hook (Ref a )
@@ -289,12 +270,6 @@ foreign import useLayoutEffect_
289
270
290
271
foreign import data Hook :: Type -> Type
291
272
292
- unHook :: forall a . Hook a -> a
293
- unHook = unsafeCoerce
294
-
295
- hook :: forall a . a -> Hook a
296
- hook = unsafeCoerce
297
-
298
273
instance functorHook :: Functor Hook where
299
274
map k = hook <<< k <<< unHook
300
275
@@ -308,3 +283,14 @@ instance bindHook :: Bind Hook where
308
283
bind fa k = k (unHook fa)
309
284
310
285
instance monadHook :: Monad Hook
286
+
287
+ unHook :: forall a . Hook a -> a
288
+ unHook = unsafeCoerce
289
+
290
+ hook :: forall a . a -> Hook a
291
+ hook = unsafeCoerce
292
+
293
+ foreign import data HookInput :: Type
294
+
295
+ hookInput :: forall a . a -> HookInput
296
+ hookInput = unsafeCoerce
0 commit comments