From aefe6175a324b73bea581f0ead1e6ba3385dea6e Mon Sep 17 00:00:00 2001 From: Luca Bracone Date: Thu, 19 Mar 2026 17:26:20 +0100 Subject: [PATCH] accumulate nodes in View's Monad instance Previously `>>=` was extracting only the return value of the `Html` from the first action, discarding its nodes entierly. This caused all but the last node to be silently dropped when `>>=` was used manually or when the `ApplicativeDo` language extension introduced a `join` call (which uses `>>=` under the hood). The fix runs the first action to obtain its `Html` value, then delegates node accumulation to `Html`'s own `>>`, which correctly concatenates both node lists. --- src/Web/Hyperbole/View/Types.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Web/Hyperbole/View/Types.hs b/src/Web/Hyperbole/View/Types.hs index 278ab8d..7c8db99 100644 --- a/src/Web/Hyperbole/View/Types.hs +++ b/src/Web/Hyperbole/View/Types.hs @@ -56,9 +56,9 @@ instance Monad (View ctx) where (>>=) :: forall a b. View ctx a -> (a -> View ctx b) -> View ctx b -- TEST: appending Empty View ea >>= famb = View $ do - a :: a <- (.value) <$> ea - let View eb :: View ctx b = famb a - eb + ha <- ea + let View eb = famb ha.value + (ha >>) <$> eb -- Context -----------------------------------------