Skip to content

Commit 2939018

Browse files
committed
Rename newtypeHook -> coerceHook
1 parent b6c539a commit 2939018

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

examples/refs/src/Refs.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Data.Nullable (Nullable, null)
88
import Effect (Effect)
99
import Math (pow, sqrt)
1010
import React.Basic.DOM as R
11-
import React.Basic.Hooks (type (/\), Hook, ReactComponent, Ref, UseEffect, UseRef, UseState, component, element, fragment, newtypeHook, readRefMaybe, useEffect, useRef, useState, (/\))
11+
import React.Basic.Hooks (type (/\), Hook, ReactComponent, Ref, UseEffect, UseRef, UseState, component, element, fragment, coerceHook, readRefMaybe, useEffect, useRef, useState, (/\))
1212
import React.Basic.Hooks as React
1313
import Unsafe.Coerce (unsafeCoerce)
1414
import Web.DOM (Node)
@@ -51,7 +51,7 @@ derive instance ntUseNodeDistance :: Newtype (UseNodeDistance hooks) _
5151

5252
useNodeDistanceFromMouse :: Hook UseNodeDistance (Int /\ (Ref (Nullable Node)))
5353
useNodeDistanceFromMouse =
54-
newtypeHook React.do
54+
coerceHook React.do
5555
elementRef <- useRef null
5656
mouseDistance /\ setMouseDistance <- useState 0
5757
useEffect unit do

src/React/Basic/Hooks.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import Effect.Uncurried (EffectFn1, EffectFn2, EffectFn3, mkEffectFn1, runEffect
5656
import Prelude (bind) as Prelude
5757
import Prim.Row (class Lacks)
5858
import React.Basic (JSX, ReactComponent, ReactContext, Ref, consumer, contextConsumer, contextProvider, createContext, element, elementKeyed, empty, keyed, fragment, provider)
59-
import React.Basic.Hooks.Internal (Hook, Pure, Render, bind, discard, newtypeHook, unsafeHook, unsafeRenderEffect)
59+
import React.Basic.Hooks.Internal (Hook, Pure, Render, bind, discard, coerceHook, unsafeHook, unsafeRenderEffect)
6060
import Unsafe.Coerce (unsafeCoerce)
6161
import Unsafe.Reference (unsafeRefEq)
6262

src/React/Basic/Hooks/Aff.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Data.Maybe (Maybe(..))
66
import Data.Newtype (class Newtype)
77
import Effect.Aff (Aff, error, killFiber, launchAff_, runAff)
88
import Effect.Exception (Error)
9-
import React.Basic.Hooks (Hook, UseEffect, UseState, newtypeHook, useEffect, useState, (/\))
9+
import React.Basic.Hooks (Hook, UseEffect, UseState, coerceHook, useEffect, useState, (/\))
1010
import React.Basic.Hooks as React
1111

1212
newtype UseAff key a hooks
@@ -24,7 +24,7 @@ useAff ::
2424
Aff a ->
2525
Hook (UseAff key a) (Result a)
2626
useAff key aff =
27-
newtypeHook React.do
27+
coerceHook React.do
2828
result /\ setResult <- useState Nothing
2929
useEffect key do
3030
setResult (const Nothing)

src/React/Basic/Hooks/Internal.purs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module React.Basic.Hooks.Internal
22
( Render
3-
, newtypeHook
3+
, coerceHook
44
, unsafeHook
55
, unsafeRenderEffect
66
, Pure
@@ -52,12 +52,12 @@ newtype Render x y a
5252
-- |
5353
-- |
5454
-- |
55-
newtypeHook ::
55+
coerceHook ::
5656
forall hooks oldHook newHook a.
5757
Newtype newHook oldHook =>
5858
Render hooks oldHook a ->
5959
Render hooks newHook a
60-
newtypeHook (Render a) = Render a
60+
coerceHook (Render a) = Render a
6161

6262
-- | Promote an arbitrary Effect to a Hook.
6363
-- |
@@ -66,7 +66,7 @@ newtypeHook (Render a) = Render a
6666
-- | may cause them to be run many times by React.
6767
-- | This function is primarily for constructing
6868
-- | new hooks using the FFI. If you just want to
69-
-- | alias a safe hook's effects, prefer `newtypeHook`.
69+
-- | alias a safe hook's effects, prefer `coerceHook`.
7070
unsafeHook ::
7171
forall newHook a.
7272
Effect a -> Hook newHook a

0 commit comments

Comments
 (0)