From bf9289b1e4f31ae02b376cd96966d4832b8b82f9 Mon Sep 17 00:00:00 2001 From: Slava Gorbunov Date: Wed, 8 May 2024 22:03:14 +0300 Subject: [PATCH 1/4] Fix build for ghc-9.6 --- reflex-dom-core/reflex-dom-core.cabal | 32 +++++++++---------- .../src/Reflex/Dom/Builder/Class.hs | 19 +++++------ .../src/Reflex/Dom/Builder/Immediate.hs | 2 ++ .../src/Reflex/Dom/Builder/Static.hs | 2 ++ reflex-dom-core/src/Reflex/Dom/Prerender.hs | 2 ++ reflex-dom-core/src/Reflex/Dom/WebSocket.hs | 2 +- .../src/Reflex/Dom/Widget/Basic.hs | 1 + .../src/Reflex/Dom/Widget/Input.hs | 1 + 8 files changed, 35 insertions(+), 26 deletions(-) diff --git a/reflex-dom-core/reflex-dom-core.cabal b/reflex-dom-core/reflex-dom-core.cabal index 84b0aecc..127245a2 100644 --- a/reflex-dom-core/reflex-dom-core.cabal +++ b/reflex-dom-core/reflex-dom-core.cabal @@ -68,20 +68,20 @@ library hs-source-dirs: src build-depends: aeson >= 0.8 && < 2.2, - base >= 4.7 && < 4.15, + base >= 4.7 && < 4.19, bifunctors >= 4.2 && < 6, - bimap >= 0.3 && < 0.5, + bimap >= 0.3 && < 0.6, blaze-builder >= 0.4.1 && < 0.5, - bytestring == 0.10.*, + bytestring >= 0.10 && < 0.12, case-insensitive < 1.3, - commutative-semigroups >=0.1 && <0.2, + commutative-semigroups >=0.1 && <0.3, containers >= 0.6 && < 0.7, - constraints >= 0.9 && < 0.14, + constraints >= 0.9 && < 0.15, contravariant >= 1.4 && < 1.6, data-default >= 0.5 && < 0.8, dependent-map >= 0.3 && < 0.5, dependent-sum >= 0.6 && < 0.8, - dependent-sum-template >= 0.1 && < 0.2, + dependent-sum-template >= 0.1 && < 0.3, directory >= 1.2 && < 1.4, exception-transformers == 0.4.*, ghcjs-dom >= 0.9.1.0 && < 0.10, @@ -90,15 +90,15 @@ library keycode >= 0.2.1 && < 0.3, lens >= 4.7 && < 5.3, monad-control >= 1.0.1 && < 1.1, - mtl >= 2.1 && < 2.3, - primitive >= 0.5 && < 0.8, + mtl >= 2.1 && < 2.4, + primitive >= 0.5 && < 0.9, random >= 1.1 && < 1.3, ref-tf >= 0.4 && < 0.6, reflex >= 0.8.2.1 && < 1, - semigroups >= 0.16 && < 0.20, + semigroups >= 0.16 && < 0.21, stm >= 2.4 && < 2.6, - text == 1.2.*, - transformers >= 0.3 && < 0.6, + text >= 1.2 && < 2.1, + transformers >= 0.3 && < 0.7, network-uri >= 2.6.1 && < 2.7, zenc == 0.1.* @@ -110,15 +110,15 @@ library else hs-source-dirs: src-ghc if !os(windows) - build-depends: unix == 2.7.* + build-depends: unix >= 2.7 && <2.9 if flag(split-these) build-depends: - semialign >= 1 && < 1.3, + semialign >= 1 && < 1.4, these >= 1 && < 1.3 else build-depends: - these >= 0.4 && < 0.9 + these >= 0.4 && < 1.0 exposed-modules: Foreign.JavaScript.TH @@ -169,8 +169,8 @@ library if flag(use-template-haskell) build-depends: - dependent-sum-template >= 0.1 && < 0.2, - template-haskell >= 2.12.0 && < 2.17 + dependent-sum-template >= 0.1 && < 0.3, + template-haskell >= 2.12.0 && < 2.23 other-extensions: TemplateHaskell cpp-options: -DUSE_TEMPLATE_HASKELL other-modules: diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs index c75eb501..075318a2 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs @@ -47,6 +47,7 @@ import Reflex.Requester.Base import qualified Control.Category import Control.Lens hiding (element) +import Control.Monad.Fix import Control.Monad.Reader import qualified Control.Monad.State as Lazy import Control.Monad.State.Strict @@ -307,6 +308,15 @@ inputElementConfig_elementConfig f (InputElementConfig a b c d e) = (\e' -> Inpu {-# INLINE inputElementConfig_elementConfig #-} #endif +instance (Reflex t, er ~ EventResult, DomSpace s) => Default (ElementConfig er t s) where + {-# INLINABLE def #-} + def = ElementConfig + { _elementConfig_namespace = Nothing + , _elementConfig_initialAttributes = mempty + , _elementConfig_modifyAttributes = Nothing + , _elementConfig_eventSpec = def + } + instance (Reflex t, er ~ EventResult, DomSpace s) => Default (InputElementConfig er t s) where {-# INLINABLE def #-} def = InputElementConfig @@ -542,15 +552,6 @@ instance HasNamespace (ElementConfig er t m) where {-# INLINABLE namespace #-} namespace = elementConfig_namespace -instance (Reflex t, er ~ EventResult, DomSpace s) => Default (ElementConfig er t s) where - {-# INLINABLE def #-} - def = ElementConfig - { _elementConfig_namespace = Nothing - , _elementConfig_initialAttributes = mempty - , _elementConfig_modifyAttributes = Nothing - , _elementConfig_eventSpec = def - } - instance (DomBuilder t m, PerformEvent t m, MonadFix m, MonadHold t m) => DomBuilder t (PostBuildT t m) where type DomBuilderSpace (PostBuildT t m) = DomBuilderSpace m wrapRawElement e = lift . wrapRawElement e diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs index fce08d03..031997ba 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs @@ -120,7 +120,9 @@ module Reflex.Dom.Builder.Immediate import Control.Concurrent import Control.Exception (bracketOnError) import Control.Lens (Identity(..), imapM_, iforM_, (^.), makeLenses) +import Control.Monad import Control.Monad.Exception +import Control.Monad.Fix import Control.Monad.Primitive import Control.Monad.Reader import Control.Monad.Ref diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs index 140c25ae..b2d94deb 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs @@ -18,7 +18,9 @@ module Reflex.Dom.Builder.Static where import Data.IORef (IORef) import Blaze.ByteString.Builder.Html.Utf8 import Control.Lens hiding (element) +import Control.Monad import Control.Monad.Exception +import Control.Monad.Fix import Control.Monad.Identity import Control.Monad.Primitive import Control.Monad.Ref diff --git a/reflex-dom-core/src/Reflex/Dom/Prerender.hs b/reflex-dom-core/src/Reflex/Dom/Prerender.hs index b7e9cbda..3fbf0cb9 100644 --- a/reflex-dom-core/src/Reflex/Dom/Prerender.hs +++ b/reflex-dom-core/src/Reflex/Dom/Prerender.hs @@ -22,6 +22,8 @@ module Reflex.Dom.Prerender , PrerenderBaseConstraints ) where +import Control.Monad +import Control.Monad.Fix import Control.Monad.Primitive (PrimMonad(..)) import Control.Monad.Reader import Control.Monad.Ref (MonadRef(..), MonadAtomicRef(..)) diff --git a/reflex-dom-core/src/Reflex/Dom/WebSocket.hs b/reflex-dom-core/src/Reflex/Dom/WebSocket.hs index 13e6fedc..e696ede9 100644 --- a/reflex-dom-core/src/Reflex/Dom/WebSocket.hs +++ b/reflex-dom-core/src/Reflex/Dom/WebSocket.hs @@ -40,7 +40,7 @@ import Control.Concurrent import Control.Concurrent.STM import Control.Exception import Control.Lens -import Control.Monad hiding (forM, forM_, mapM, mapM_, sequence) +import Control.Monad hiding (forM, mapM, mapM_, sequence) import Control.Monad.IO.Class import Control.Monad.State import Data.Aeson diff --git a/reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs b/reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs index 66e6d5ab..c6dffa40 100644 --- a/reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs +++ b/reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs @@ -72,6 +72,7 @@ import Reflex.Workflow import Control.Arrow import Control.Lens hiding (children, element) +import Control.Monad.Fix import Control.Monad.Reader hiding (forM, forM_, mapM, mapM_, sequence, sequence_) import Data.Align import Data.Default diff --git a/reflex-dom-core/src/Reflex/Dom/Widget/Input.hs b/reflex-dom-core/src/Reflex/Dom/Widget/Input.hs index 2c67fcd3..086a8ed1 100644 --- a/reflex-dom-core/src/Reflex/Dom/Widget/Input.hs +++ b/reflex-dom-core/src/Reflex/Dom/Widget/Input.hs @@ -19,6 +19,7 @@ module Reflex.Dom.Widget.Input (module Reflex.Dom.Widget.Input, def, (&), (.~)) import Prelude import Control.Lens hiding (element, ix) +import Control.Monad import Control.Monad.Fix import Control.Monad.IO.Class import Control.Monad.Reader From 124706fc0b96e3af67f98ddc29880b4c282144af Mon Sep 17 00:00:00 2001 From: Slava Gorbunov Date: Mon, 13 May 2024 20:53:32 +0300 Subject: [PATCH 2/4] Make reflex-dom-core buildable on recent ghc js backend --- reflex-dom-core/reflex-dom-core.cabal | 4 ++-- .../src-ghcjs/Foreign/JavaScript/Internal/Utils.hs | 5 +++++ reflex-dom-core/src/Foreign/JavaScript/TH.hs | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/reflex-dom-core/reflex-dom-core.cabal b/reflex-dom-core/reflex-dom-core.cabal index 127245a2..d319f2b2 100644 --- a/reflex-dom-core/reflex-dom-core.cabal +++ b/reflex-dom-core/reflex-dom-core.cabal @@ -102,11 +102,11 @@ library network-uri >= 2.6.1 && < 2.7, zenc == 0.1.* - if impl(ghcjs) + if impl(ghcjs) || arch(javascript) hs-source-dirs: src-ghcjs build-depends: ghcjs-base, - hashable >= 1.2 && < 1.4 + hashable >= 1.2 && < 1.5 else hs-source-dirs: src-ghc if !os(windows) diff --git a/reflex-dom-core/src-ghcjs/Foreign/JavaScript/Internal/Utils.hs b/reflex-dom-core/src-ghcjs/Foreign/JavaScript/Internal/Utils.hs index 73d7a886..06cb003e 100644 --- a/reflex-dom-core/src-ghcjs/Foreign/JavaScript/Internal/Utils.hs +++ b/reflex-dom-core/src-ghcjs/Foreign/JavaScript/Internal/Utils.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE JavaScriptFFI #-} @@ -9,7 +10,11 @@ module Foreign.JavaScript.Internal.Utils import GHCJS.Concurrent import GHCJS.DOM.Types (JSM, JSVal, RequestAnimationFrameCallback (..)) +#ifdef __GHCJS__ import GHCJS.Foreign.Callback (releaseCallback) +#else +import GHC.JS.Foreign.Callback (releaseCallback) +#endif freeRequestAnimationFrameCallback :: RequestAnimationFrameCallback -> JSM () freeRequestAnimationFrameCallback (RequestAnimationFrameCallback cb) = releaseCallback cb diff --git a/reflex-dom-core/src/Foreign/JavaScript/TH.hs b/reflex-dom-core/src/Foreign/JavaScript/TH.hs index 602bd421..bf2080cc 100644 --- a/reflex-dom-core/src/Foreign/JavaScript/TH.hs +++ b/reflex-dom-core/src/Foreign/JavaScript/TH.hs @@ -35,8 +35,12 @@ import qualified GHCJS.Buffer as JS import GHCJS.DOM.Types (MonadJSM) import qualified GHCJS.DOM.Types as JS import qualified GHCJS.Foreign as JS +#ifdef __GHCJS__ import qualified GHCJS.Foreign.Callback as JS import qualified GHCJS.Foreign.Callback.Internal (Callback (..)) +#else +import qualified GHC.JS.Foreign.Callback as JS +#endif import qualified JavaScript.Array as JS import qualified JavaScript.Array.Internal (SomeJSArray (..)) import qualified JavaScript.Object as JS From b418cfbadd2f94f823db222fc0a77f14f36de283 Mon Sep 17 00:00:00 2001 From: Slava Gorbunov Date: Fri, 7 Jun 2024 18:24:15 +0300 Subject: [PATCH 3/4] Support new js backend syntax --- reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs index 031997ba..ee7b5136 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs @@ -466,7 +466,11 @@ removeSubsequentNodes :: (MonadJSM m, IsNode n) => n -> m () #ifdef ghcjs_HOST_OS --NOTE: Although wrapping this javascript in a function seems unnecessary, GHCJS's optimizer will break it if it is entered without that wrapping (as of 2021-11-06) foreign import javascript unsafe +#ifdef __GHCJS__ "(function() { var n = $1; while (n['nextSibling']) { n['parentNode']['removeChild'](n['nextSibling']); }; })()" +#else + "(function(n) { while (n['nextSibling']) { n['parentNode']['removeChild'](n['nextSibling']); }; })" +#endif removeSubsequentNodes_ :: DOM.Node -> IO () removeSubsequentNodes n = liftJSM $ removeSubsequentNodes_ (toNode n) #else @@ -489,7 +493,11 @@ extractBetweenExclusive :: (MonadJSM m, IsNode start, IsNode end) => DOM.Documen #ifdef ghcjs_HOST_OS --NOTE: Although wrapping this javascript in a function seems unnecessary, GHCJS's optimizer will break it if it is entered without that wrapping (as of 2021-11-06) foreign import javascript unsafe +#ifdef __GHCJS__ "(function() { var df = $1; var s = $2; var e = $3; var x; for(;;) { x = s['nextSibling']; if(e===x) { break; }; df['appendChild'](x); } })()" +#else + "(function(df, s, e) { var x; for(;;) { x = s['nextSibling']; if(e===x) { break; }; df['appendChild'](x); } })" +#endif extractBetweenExclusive_ :: DOM.DocumentFragment -> DOM.Node -> DOM.Node -> IO () extractBetweenExclusive df s e = liftJSM $ extractBetweenExclusive_ df (toNode s) (toNode e) #else @@ -510,7 +518,11 @@ extractUpTo :: (MonadJSM m, IsNode start, IsNode end) => DOM.DocumentFragment -> #ifdef ghcjs_HOST_OS --NOTE: Although wrapping this javascript in a function seems unnecessary, GHCJS's optimizer will break it if it is entered without that wrapping (as of 2017-09-04) foreign import javascript unsafe +#ifdef __GHCJS__ "(function() { var x = $2; while(x !== $3) { var y = x['nextSibling']; $1['appendChild'](x); x = y; } })()" +#else + "(function(_, x, $3) { while(x !== $3) { var y = x['nextSibling']; $1['appendChild'](x); x = y; } })" +#endif extractUpTo_ :: DOM.DocumentFragment -> DOM.Node -> DOM.Node -> IO () extractUpTo df s e = liftJSM $ extractUpTo_ df (toNode s) (toNode e) #else From 8365fb5c3fd4ad537b756de4569b6a213b505389 Mon Sep 17 00:00:00 2001 From: Alexandre Esteves Date: Sat, 2 Nov 2024 00:08:58 +0000 Subject: [PATCH 4/4] Fix semantic merge conflict --- reflex-dom-core/src/Reflex/Dom/Builder/Class.hs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs index 1d89783e..20eca905 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs @@ -279,15 +279,6 @@ elementConfig_eventSpec f (ElementConfig a b c d) = (\d' -> ElementConfig a b c {-# INLINE elementConfig_eventSpec #-} #endif -instance (Reflex t, er ~ EventResult, DomSpace s) => Default (ElementConfig er t s) where - {-# INLINABLE def #-} - def = ElementConfig - { _elementConfig_namespace = Nothing - , _elementConfig_initialAttributes = mempty - , _elementConfig_modifyAttributes = Nothing - , _elementConfig_eventSpec = def - } - data Element er d t = Element { _element_events :: EventSelector t (WrapArg er EventName) --TODO: EventSelector should have two arguments , _element_raw :: RawElement d