Skip to content

add hydration#836

Open
srghma wants to merge 4 commits intopurescript-halogen:masterfrom
srghma:main
Open

add hydration#836
srghma wants to merge 4 commits intopurescript-halogen:masterfrom
srghma:main

Conversation

@srghma
Copy link
Copy Markdown

@srghma srghma commented Jul 8, 2025

Serhii Khoma added 4 commits April 19, 2025 19:16
…ched)

```purs
module Foo where

import Prelude

import Data.Tuple
import Effect.Uncurried as EFn

renderComponentSlot :: EFn.EffectFn1 String (Tuple Int (EFn.EffectFn2 Int Int Int))
renderComponentSlot = EFn.mkEffectFn1 \cs -> pure (Tuple 1 patch)

patch :: EFn.EffectFn2 Int Int Int
patch = EFn.mkEffectFn2 \st slot -> map fst $ EFn.runEffectFn1 renderComponentSlot ""
```

gives

```js
import * as Data_Functor from "../Data.Functor/index.js";
import * as Data_Tuple from "../Data.Tuple/index.js";
import * as Effect from "../Effect/index.js";
var $runtime_lazy = function (name, moduleName, init) {
    var state = 0;
    var val;
    return function (lineNumber) {
        if (state === 2) return val;
        if (state === 1) throw new ReferenceError(name + " was needed before it finished initializing (module " + moduleName + ", line " + lineNumber + ")", moduleName, lineNumber);
        state = 1;
        val = init();
        state = 2;
        return val;
    };
};
var map = /* #__PURE__ */ Data_Functor.map(Effect.functorEffect);
var $lazy_patch = /* #__PURE__ */ $runtime_lazy("patch", "Foo", function () {
    return function (st, slot) {
        return map(Data_Tuple.fst)(function () {
            return $lazy_renderComponentSlot(18)("");
        })();
    };
});
var $lazy_renderComponentSlot = /* #__PURE__ */ $runtime_lazy("renderComponentSlot", "Foo", function () {
    return function (cs) {
        var step = $lazy_patch(14);
        return new Data_Tuple.Tuple(1, step);
    };
});
var patch = /* #__PURE__ */ $lazy_patch(17);
var renderComponentSlot = /* #__PURE__ */ $lazy_renderComponentSlot(9);
export {
    renderComponentSlot,
    patch
};
```

but

```purs
module Foo where

import Prelude

import Data.Tuple
import Effect.Uncurried as EFn

renderComponentSlot :: EFn.EffectFn1 String (Tuple Int (EFn.EffectFn2 Int Int Int))
renderComponentSlot = EFn.mkEffectFn1 \cs -> pure (Tuple 1 patch)

x = EFn.runEffectFn1 renderComponentSlot ""

patch :: EFn.EffectFn2 Int Int Int
patch = EFn.mkEffectFn2 \st slot -> map fst $ x
```

throws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant