From 3315863bb36798415802337961e7d6756fae2dd2 Mon Sep 17 00:00:00 2001 From: qwbarch Date: Sun, 16 Jul 2023 01:02:02 -0400 Subject: [PATCH] Cleanup --- example/Main.purs | 10 ++++------ src/Halogen/Typewriter.purs | 8 ++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/example/Main.purs b/example/Main.purs index 5dbd9a9..576b6d4 100644 --- a/example/Main.purs +++ b/example/Main.purs @@ -38,12 +38,10 @@ component = mkComponent { initialState: const unit , render - , eval: - mkEval $ - defaultEval - { handleAction = handleAction - , initialize = Just Initialize - } + , eval: mkEval defaultEval + { handleAction = handleAction + , initialize = Just Initialize + } } where handleAction = case _ of diff --git a/src/Halogen/Typewriter.purs b/src/Halogen/Typewriter.purs index 9ee3a7c..4a451f4 100644 --- a/src/Halogen/Typewriter.purs +++ b/src/Halogen/Typewriter.purs @@ -3,10 +3,9 @@ module Halogen.Typewriter where import Prelude hiding (div) import CSS (opacity) -import Control.Monad.Rec.Class (forever) import Control.Monad.State (get) import Data.Foldable (foldMap) -import Data.Lens (view, (%=), (.=)) +import Data.Lens (view, (%=), (.=), (<>=)) import Data.List.Lazy (List, head, tail) import Data.Maybe (Maybe(..), fromMaybe) import Data.Newtype (unwrap) @@ -124,7 +123,7 @@ typewriter = mkComponent { initialState, render, eval } , jitter: input.jitter , running: true } - eval = mkEval (defaultEval { handleAction = handleAction, initialize = Just Initialize }) + eval = mkEval defaultEval { handleAction = handleAction, initialize = Just Initialize } -- The defined class names do nothing by default. -- These are for the user's convenience, if they want to change styles for the respective classes. @@ -162,6 +161,7 @@ typewriter = mkComponent { initialState, render, eval } case head state.words of Nothing -> do running .= false + cursorHidden .= true raise Finished Just word -> do case state.mode of @@ -177,7 +177,7 @@ typewriter = mkComponent { initialState, render, eval } coefficient <- liftEffect $ state.jitter sleep (_ * coefficient) typeDelay -- Add the next letter to outputText. - outputText %= (_ <> singleton letter) + outputText <>= singleton letter Deleting -> -- When outputText is empty, start typing. if null state.outputText then mode .= Typing