Skip to content

Commit

Permalink
Merge pull request #17 from ford-prefect/doc
Browse files Browse the repository at this point in the history
Add some basic documentation to Render, Pure and Hook
  • Loading branch information
megamaddu authored Feb 26, 2020
2 parents 2ae2054 + be06f1d commit 9175d48
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/React/Basic/Hooks/Internal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ import Type.Equality (class TypeEquals)
-- | body, i.e. during "render". This includes hooks and ends with
-- | returning JSX (see `pure`), but does not allow arbitrary side
-- | effects.
-- |
-- | The `x` and `y` type arguments represent the stack of effects that this
-- | `Render` implements, with `x` being the stack at the start of this
-- | `Render`, and `y` the stack at the end.
-- |
-- | See
-- | [purescript-indexed-monad](https://pursuit.purescript.org/packages/purescript-indexed-monad)
-- | to understand how the order of the stack is enforced at the type level.
newtype Render x y a
= Render (Effect a)

Expand Down Expand Up @@ -115,10 +123,16 @@ unsafeHook = Render
unsafeRenderEffect :: forall a. Effect a -> Pure a
unsafeRenderEffect = Render

-- | Discards
-- | Type alias used to lift otherwise pure functionality into the Render type.
-- | Not commonly used.
type Pure a
= forall hooks. Render hooks hooks a

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

Expand Down

0 comments on commit 9175d48

Please sign in to comment.