Skip to content

Add some basic documentation to Render, Pure and Hook #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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