Skip to content

Commit 9175d48

Browse files
authoredFeb 26, 2020
Merge pull request #17 from ford-prefect/doc
Add some basic documentation to Render, Pure and Hook
2 parents 2ae2054 + be06f1d commit 9175d48

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed
 

‎src/React/Basic/Hooks/Internal.purs

+15-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ import Type.Equality (class TypeEquals)
2323
-- | body, i.e. during "render". This includes hooks and ends with
2424
-- | returning JSX (see `pure`), but does not allow arbitrary side
2525
-- | effects.
26+
-- |
27+
-- | The `x` and `y` type arguments represent the stack of effects that this
28+
-- | `Render` implements, with `x` being the stack at the start of this
29+
-- | `Render`, and `y` the stack at the end.
30+
-- |
31+
-- | See
32+
-- | [purescript-indexed-monad](https://pursuit.purescript.org/packages/purescript-indexed-monad)
33+
-- | to understand how the order of the stack is enforced at the type level.
2634
newtype Render x y a
2735
= Render (Effect a)
2836

@@ -115,10 +123,16 @@ unsafeHook = Render
115123
unsafeRenderEffect :: forall a. Effect a -> Pure a
116124
unsafeRenderEffect = Render
117125

118-
-- | Discards
126+
-- | Type alias used to lift otherwise pure functionality into the Render type.
127+
-- | Not commonly used.
119128
type Pure a
120129
= forall hooks. Render hooks hooks a
121130

131+
-- | Type alias for Render representing a hook.
132+
-- |
133+
-- | The `newHook` argument is a type constructor which takes a set of existing
134+
-- | effects and generates a type with a new set of effects (produced by this
135+
-- | hook) stacked on top.
122136
type Hook (newHook :: Type -> Type) a
123137
= forall hooks. Render hooks (newHook hooks) a
124138

0 commit comments

Comments
 (0)