Skip to content

Releases: thomashoneyman/purescript-halogen-hooks

v0.6.3

25 Sep 15:08
Compare
Choose a tag to compare
  • Update package sets to a 0.15.4-compatible set.

v0.6.2

25 Sep 14:43
0a0bb7c
Compare
Choose a tag to compare
  • Make initialization safe in the presence of interruptions (@jterbraak in #76)

v0.6.1

01 Sep 20:02
0316ba4
Compare
Choose a tag to compare
  • Updates Halogen Hooks for compatibility with purescript-backend-optimizer. The internal implementation performed unsafe effects in let bindings and did not use the result, which leads the inliner to remove these bindings. This release fixes the issue. (#75 by @thomashoneyman).

v0.6.0

02 May 20:07
cbbf565
Compare
Choose a tag to compare

Breaking changes (😱!!!):

  • Add support for PureScript 0.15 and Halogen 7, dropping support for previous versions of the compiler and Halogen. (#74 by @CarstenKoenig)
    This is a breaking change because of the upgrade in dependencies only. The code continues to work as-is.

v0.5.1

24 Feb 02:37
cf6f606
Compare
Choose a tag to compare

Internal

Don't ignore the .purs.json file in the .gitignore

v0.5.0

16 Mar 05:17
Compare
Choose a tag to compare

Breaking changes (😱!!!):

  • Add support for PureScript 0.14 and Halogen 6, dropping support for previous versions of the compiler and Halogen. (#71 by @CarstenKoenig, #72 by @thomashoneyman)

  • Move to a single index for hook types. (#32 by @thomashoneyman)

    Using a single index for Hook types simplifies the Hooks implementation and makes defining your own Hooks easier and less confusing. It also allows the library to drop its dependency on indexed-monad.

    Previously, Hooks were defined as an indexed monad with parameters to track the before and after state of a Hook bind:

    -- Old approach
    type Hook m (newHooks :: Type -> Type) a =
      forall hooks. Hooked m hooks (newHooks hooks) a
    
    newtype Hooked m hooks newHooks a =
      Hooked (Indexed (Free (UseHookF m)) hooks newHooks a)
    
    bind
      :: forall a b x y z m
      . Hooked m hooks hooks' a
      -> (a -> Hooked m hooks' newHooks b)
      -> Hooked m hooks newHooks b

    Now, Hooks are defined with a custom HookType and each bind produces a new, single index made up of all the hook types in use.

    -- New approach
    data HookType
    
    newtype Hook m (h :: HookType) a = Hook (Free (UseHookF m) a)
    
    foreign import data Hooked :: HookType -> HookType -> HookType
    infixr 1 type Hooked as <>
    
    bind
      :: forall h h' m a b
       . Hook m h a
      -> (a -> Hook m h' b)
      -> Hook m (h <> h') b

    This is a breaking change because it changes how you define your Hook types in Halogen Hooks. First, Hooks are now written in the order they occur.

    -- Assume UseState, then UseEffect, then UseRef in the code
    
    -- Previously: this reads backwards, as state transitions 'away from' the
    -- hooks type variable
    UseRef Int
      (UseEffect
      (UseState Int hooks))
    
    -- Now: this reads in the order hooks are applied in the code, where
    -- `Pure` represents the call to `pure`
    UseState Int
      <> UseEffect
      <> UseRef Int
      <> Hooks.Pure

    Second, you no longer use a newtype to define Hooks. Instead, you'll foreign import a data type to represent your Hook type and use the HookNewtype type class.

    -- Before
    type UseX' hooks = UseState Int (UseEffect hooks)
    
    newtype UseX hooks = UseX (UseX' hooks)
    
    derive instance newtypeUseX :: Newtype (UseX hooks) _
    
    -- After
    type UseX' = UseEffect <> UseState Int <> Hooks.Pure
    
    foreign import data UseX :: Hooks.HookType
    
    instance newtypeUseX :: HookNewtype UseX UseX'

New features:

Bugfixes:

Other improvements:

  • Docs: Added technical documentation that covers the main concepts used in the internal implementation (#59 by @thomashoneyman).
  • Docs: Added a changelog to record changes to the library over time (#62 by @thomashoneyman).
  • Tests: Added performance tests to measure the performance impact of changes (#53 by @thomashoneyman, #56 by @thomashoneyman).
  • Updated the Nix shell to use PureScript 0.14 tooling

v0.4.3

18 Jun 02:04
Compare
Choose a tag to compare

This release ensures that state-modifying HookM code can't be passed from one component to another without throwing an immediate exception. HookM code that modifies state which is written in one component must be evaluated in that component.

  • Throw exception if state-modifying HookM code passed between components (#44)
  • Update Spago package set and generated Bowerfile

v0.4.2

05 Jun 00:34
86d681f
Compare
Choose a tag to compare

This release updates module exports.

  • Re-export memoComponent from the main Hooks module (#43)

v0.4.1

18 May 20:37
5a28f6c
Compare
Choose a tag to compare

This release includes small internal performance improvements.

Improvements:

Use substFree instead of foldFree internally (#33)

Using foldFree is convenient, but it incurs some overhead due to a MonadRec constraint on the monad you interpret into. Switching to substFree eliminates this overhead, giving the library a modest performance improvement.

v0.4.0

14 May 18:21
4202125
Compare
Choose a tag to compare

This release changes how users update state in Hooks.

Breaking changes (😱!!!):

Return to state identifiers instead of returning just a modify function (#31)

The previous release replaced state tokens with a simply modify function returned by the useState hook. For a variety of reasons this turned out to be not a change worth making, and it has now been reverted. See #30 for more details on why this happened.

If you liked using a modify function instead of a token, you can still do that:

state /\ modifyState <- map Hooks.modify_ <$> Hooks.useState 0
let handleClick = modifyState (_ + 1)
Hooks.pure ...