Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building with ghc-9.8 js backend #471

Merged
merged 6 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions reflex-dom-core/reflex-dom-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's with this bound since ghc 9.8 brings base 4.19
https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history

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,
Expand All @@ -90,35 +90,35 @@ 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.*

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)
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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE JavaScriptFFI #-}

Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions reflex-dom-core/src/Foreign/JavaScript/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions reflex-dom-core/src/Reflex/Dom/Builder/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -464,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
Expand All @@ -487,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
Expand All @@ -508,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
Expand Down
2 changes: 2 additions & 0 deletions reflex-dom-core/src/Reflex/Dom/Builder/Static.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions reflex-dom-core/src/Reflex/Dom/Prerender.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..))
Expand Down
2 changes: 1 addition & 1 deletion reflex-dom-core/src/Reflex/Dom/WebSocket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions reflex-dom-core/src/Reflex/Dom/Widget/Input.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading