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

Build on GHC 9.10 #480

Merged
merged 13 commits into from
Jan 12, 2025
7 changes: 4 additions & 3 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
strategy:
matrix:
ghc: ['8.6', '8.8', '8.10', '9.0', '9.2']
ghc: ['8.6', '8.8', '8.10', '9.0', '9.2', '9.4', '9.6', '9.8', '9.10']
os: ['ubuntu-latest']
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -37,5 +37,6 @@ jobs:
cabal build --only-dependencies --enable-tests --enable-benchmarks all
- name: Build
run: cabal build --enable-tests --enable-benchmarks all
- name: Run tests
run: cabal test all
# Temporarily disabled until either a newer hlint is released or chrome-test-utils is released on hackage
# - name: Run tests
# run: cabal test all
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ packages:
reflex-dom/
chrome-test-utils/
reflex-dom-test-selenium/

tests: True
benchmarks: True
2 changes: 1 addition & 1 deletion cabal.project-nogtk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ packages:
reflex-dom/

package reflex-dom-core
flags: -hydration-tests -gc-tests
flags: -hlint-tests -hydration-tests -gc-tests

package reflex-dom
flags: +use-warp -webkit2gtk
1 change: 0 additions & 1 deletion chrome-test-utils/src/Test/Util/ChromeFlags.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
module Test.Util.ChromeFlags where

import Data.Semigroup
import Data.Text
import System.IO.Temp

Expand Down
21 changes: 14 additions & 7 deletions reflex-dom-core/reflex-dom-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,26 @@ flag gc-tests
default: True
manual: True

flag hlint-tests
description: Whether to run the hlint tests
default: False
manual: True

library
hs-source-dirs: src
build-depends:
aeson >= 0.8 && < 2.3,
base >= 4.7 && < 4.20,
base >= 4.7 && < 4.21,
bifunctors >= 4.2 && < 6,
bimap >= 0.3 && < 0.6,
blaze-builder >= 0.4.1 && < 0.5,
bytestring >= 0.10 && < 0.13,
case-insensitive < 1.3,
commutative-semigroups >=0.1 && <0.3,
containers >= 0.6 && < 0.7,
containers >= 0.6 && < 0.8,
constraints >= 0.9 && < 0.15,
contravariant >= 1.4 && < 1.6,
data-default >= 0.5 && < 0.8,
data-default >= 0.5 && < 0.9,
dependent-map >= 0.3 && < 0.5,
dependent-sum >= 0.6 && < 0.8,
dependent-sum-template >= 0.1 && < 0.3,
Expand All @@ -88,16 +93,16 @@ library
jsaddle >= 0.9.0.0 && < 0.10,
-- keycode-0.2 has a bug on firefox
keycode >= 0.2.1 && < 0.3,
lens >= 4.7 && < 5.3,
lens >= 4.7 && < 5.4,
monad-control >= 1.0.1 && < 1.1,
mtl >= 2.1 && < 2.4,
primitive >= 0.5 && < 0.9,
random >= 1.1 && < 1.3,
primitive >= 0.5 && < 0.10,
random >= 1.1 && < 1.4,
ref-tf >= 0.4 && < 0.6,
reflex >= 0.8.2.1 && < 1,
semigroups >= 0.16 && < 0.21,
stm >= 2.4 && < 2.6,
text >= 1.2 && < 2.1,
text >= 1.2 && < 2.2,
transformers >= 0.3 && < 0.7,
network-uri >= 2.6.1 && < 2.7,
zenc == 0.1.*
Expand Down Expand Up @@ -184,6 +189,8 @@ test-suite hlint
main-is: hlint.hs
type: exitcode-stdio-1.0
default-language: Haskell98
if !flag(hlint-tests)
buildable: False

test-suite hydration
build-depends: base
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ForeignFunctionInterface #-}
#ifdef __ghcjs_HOST_OS
{-# LANGUAGE JavaScriptFFI #-}
#endif

module Foreign.JavaScript.Internal.Utils
( synchronously
Expand All @@ -10,7 +12,7 @@ module Foreign.JavaScript.Internal.Utils

import GHCJS.Concurrent
import GHCJS.DOM.Types (JSM, JSVal, RequestAnimationFrameCallback (..))
#ifdef __GHCJS__
#if __GLASGOW_HASKELL__ < 900
import GHCJS.Foreign.Callback (releaseCallback)
#else
import GHC.JS.Foreign.Callback (releaseCallback)
Expand Down
2 changes: 1 addition & 1 deletion reflex-dom-core/src/Foreign/JavaScript/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ 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__
#if __GLASGOW_HASKELL__ < 900
import qualified GHCJS.Foreign.Callback as JS
import qualified GHCJS.Foreign.Callback.Internal (Callback (..))
#else
Expand Down
27 changes: 14 additions & 13 deletions reflex-dom-core/src/Reflex/Dom/Builder/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{-# LANGUAGE TemplateHaskell #-}
#endif
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Reflex.Dom.Builder.Class
( module Reflex.Dom.Builder.Class
Expand Down Expand Up @@ -54,11 +55,11 @@ import Control.Monad.State.Strict
import Control.Monad.Trans.Control
import Data.Default
import Data.Functor.Misc
import Data.Kind (Type)
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe
import Data.Proxy
import Data.Semigroup
import Data.Semigroup.Commutative
import Data.String
import Data.Text (Text)
Expand All @@ -67,20 +68,20 @@ import GHCJS.DOM.Types (JSM)
import qualified GHCJS.DOM.Types as DOM

class Default (EventSpec d EventResult) => DomSpace d where
type EventSpec d :: (EventTag -> *) -> *
type RawDocument d :: *
type RawTextNode d :: *
type RawCommentNode d :: *
type RawElement d :: *
type RawInputElement d :: *
type RawTextAreaElement d :: *
type RawSelectElement d :: *
type EventSpec d :: (EventTag -> Type) -> Type
type RawDocument d :: Type
type RawTextNode d :: Type
type RawCommentNode d :: Type
type RawElement d :: Type
type RawInputElement d :: Type
type RawTextAreaElement d :: Type
type RawSelectElement d :: Type
addEventSpecFlags :: proxy d -> EventName en -> (Maybe (er en) -> EventFlags) -> EventSpec d er -> EventSpec d er

-- | @'DomBuilder' t m@ indicates that @m@ is a 'Monad' capable of building
-- dynamic DOM in the 'Reflex' timeline @t@
class (Monad m, Reflex t, DomSpace (DomBuilderSpace m), NotReady t m, Adjustable t m) => DomBuilder t m | m -> t where
type DomBuilderSpace m :: *
type DomBuilderSpace m :: Type
textNode :: TextNodeConfig t -> m (TextNode (DomBuilderSpace m) t)
default textNode :: ( MonadTrans f
, m ~ f m'
Expand Down Expand Up @@ -160,7 +161,7 @@ class (Monad m, Reflex t, DomSpace (DomBuilderSpace m), NotReady t m, Adjustable
{-# INLINABLE wrapRawElement #-}

class DomBuilder t m => MountableDomBuilder t m where
type DomFragment m :: *
type DomFragment m :: Type
buildDomFragment :: m a -> m (DomFragment m, a)
mountDomFragment :: DomFragment m -> Event t (DomFragment m) -> m ()

Expand Down Expand Up @@ -642,7 +643,7 @@ instance (DomBuilder t m, MonadFix m, MonadHold t m, Group q, Query q, Commutati
-- * Convenience functions

class HasDomEvent t target eventName | target -> t where
type DomEventType target eventName :: *
type DomEventType target eventName :: Type
domEvent :: EventName eventName -> target -> Event t (DomEventType target eventName)

instance Reflex t => HasDomEvent t (Element EventResult d t) en where
Expand Down Expand Up @@ -749,7 +750,7 @@ instance HasDocument m => HasDocument (RequesterT t request response m)
instance HasDocument m => HasDocument (QueryT t q m)

class HasSetValue a where
type SetValue a :: *
type SetValue a :: Type
setValue :: Lens' a (SetValue a)

instance Reflex t => HasSetValue (TextAreaElementConfig er t m) where
Expand Down
5 changes: 3 additions & 2 deletions reflex-dom-core/src/Reflex/Dom/Builder/Class/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Data.Type.Equality ((:~:)(..))
import Data.GADT.Compare
(GOrdering(..), GEq(..), GCompare(..))
#endif
import Data.Kind (Type)
import Data.Text (Text)

data EventTag
Expand Down Expand Up @@ -65,7 +66,7 @@ data EventTag
| TouchendTag
| TouchcancelTag

data EventName :: EventTag -> * where
data EventName :: EventTag -> Type where
Abort :: EventName 'AbortTag
Blur :: EventName 'BlurTag
Change :: EventName 'ChangeTag
Expand Down Expand Up @@ -115,7 +116,7 @@ data EventName :: EventTag -> * where

newtype EventResult en = EventResult { unEventResult :: EventResultType en }

type family EventResultType (en :: EventTag) :: * where
type family EventResultType (en :: EventTag) :: Type where
EventResultType 'ClickTag = ()
EventResultType 'DblclickTag = (Int, Int)
EventResultType 'KeypressTag = Word
Expand Down
2 changes: 1 addition & 1 deletion reflex-dom-core/src/Reflex/Dom/Builder/Hydratable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import GHCJS.DOM.Types (MonadJSM (..))
#endif
import Reflex
import Reflex.Dom.Builder.Class
import Reflex.Dom.Builder.Immediate (HasDocument (..), hydratableAttribute)
import Reflex.Dom.Builder.Immediate (hydratableAttribute)
import Reflex.Host.Class

-- | A DomBuilder transformer that adds an attribute to all elements such that the
Expand Down
16 changes: 7 additions & 9 deletions reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ import Data.Bitraversable
import Data.Default
import Data.Dependent.Map (DMap)
import Data.Dependent.Sum
import Data.FastMutableIntMap (PatchIntMap (..))
import Data.Foldable (for_, traverse_)
import Data.Functor.Compose
import Data.Functor.Constant
Expand All @@ -140,8 +139,8 @@ import Data.Functor.Product
import Data.GADT.Compare (GCompare)
import Data.IORef
import Data.IntMap.Strict (IntMap)
import Data.Kind (Type)
import Data.Maybe
import Data.Monoid ((<>))
import Data.Some (Some(..))
import Data.String (IsString)
import Data.Text (Text)
Expand All @@ -154,7 +153,7 @@ import GHCJS.DOM.EventM (EventM, event, on)
import GHCJS.DOM.KeyboardEvent as KeyboardEvent
import GHCJS.DOM.MouseEvent
import GHCJS.DOM.Node (appendChild_, getOwnerDocumentUnchecked, getParentNodeUnchecked, setNodeValue, toNode)
import GHCJS.DOM.Types (liftJSM, askJSM, runJSM, JSM, MonadJSM, FocusEvent, IsElement, IsEvent, IsNode, KeyboardEvent, Node, TouchEvent, WheelEvent, uncheckedCastTo, ClipboardEvent)
import GHCJS.DOM.Types (liftJSM, askJSM, runJSM, JSM, MonadJSM, FocusEvent, IsElement, IsEvent, IsNode, Node, TouchEvent, WheelEvent, uncheckedCastTo)
import GHCJS.DOM.UIEvent
#ifndef ghcjs_HOST_OS
import Language.Javascript.JSaddle (call, eval) -- Avoid using eval in ghcjs. Use ffi instead
Expand All @@ -164,7 +163,6 @@ import Reflex.Class as Reflex
import Reflex.Dom.Builder.Class
import Reflex.Dynamic
import Reflex.Host.Class
import Reflex.Patch.DMapWithMove (PatchDMapWithMove(..))
import Reflex.Patch.MapWithMove (PatchMapWithMove(..))
import Reflex.PerformEvent.Base (PerformEventT)
import Reflex.PerformEvent.Class
Expand Down Expand Up @@ -466,7 +464,7 @@ 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__
#if __GLASGOW_HASKELL__ < 900
"(function() { var n = $1; while (n['nextSibling']) { n['parentNode']['removeChild'](n['nextSibling']); }; })()"
#else
"(function(n) { while (n['nextSibling']) { n['parentNode']['removeChild'](n['nextSibling']); }; })"
Expand All @@ -493,7 +491,7 @@ 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__
#if __GLASGOW_HASKELL__ < 900
"(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); } })"
Expand All @@ -518,7 +516,7 @@ 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__
#if __GLASGOW_HASKELL__ < 900
"(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; } })"
Expand Down Expand Up @@ -676,7 +674,7 @@ instance DomSpace GhcjsDomSpace where

newtype GhcjsEventFilter er en = GhcjsEventFilter (GhcjsDomEvent en -> JSM (EventFlags, JSM (Maybe (er en))))

data Pair1 (f :: k -> *) (g :: k -> *) (a :: k) = Pair1 (f a) (g a)
data Pair1 (f :: k -> Type) (g :: k -> Type) (a :: k) = Pair1 (f a) (g a)

data Maybe1 f a = Nothing1 | Just1 (f a)

Expand Down Expand Up @@ -1703,7 +1701,7 @@ instance (Adjustable t m, MonadJSM m, MonadHold t m, MonadFix m, PrimMonad m, Ra

{-# INLINABLE traverseDMapWithKeyWithAdjust' #-}
traverseDMapWithKeyWithAdjust'
:: forall s t m (k :: * -> *) v v'. (Adjustable t m, MonadHold t m, MonadFix m, MonadJSM m, PrimMonad m, GCompare k, RawDocument (DomBuilderSpace (HydrationDomBuilderT s t m)) ~ Document)
:: forall s t m (k :: Type -> Type) v v'. (Adjustable t m, MonadHold t m, MonadFix m, MonadJSM m, PrimMonad m, GCompare k, RawDocument (DomBuilderSpace (HydrationDomBuilderT s t m)) ~ Document)
=> (forall a. k a -> v a -> HydrationDomBuilderT s t m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
Expand Down
1 change: 0 additions & 1 deletion reflex-dom-core/src/Reflex/Dom/Builder/InputDisabled.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import GHCJS.DOM.Types (MonadJSM (..))
#endif
import Reflex
import Reflex.Dom.Builder.Class
import Reflex.Dom.Builder.Immediate (HasDocument (..))
import Reflex.Host.Class

-- | A DomBuilder transformer that disables all 'inputElement's,
Expand Down
7 changes: 3 additions & 4 deletions reflex-dom-core/src/Reflex/Dom/Builder/Static.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ 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
import Control.Monad.State.Strict
Expand All @@ -40,7 +39,7 @@ import qualified Data.IntMap as IntMap
import qualified Data.Map as Map
import Data.Map.Misc (applyMap)
import Data.Maybe (fromMaybe)
import Data.Monoid ((<>))
import Data.Kind (Type)
import qualified Data.Set as Set
import Data.Text (Text)
import qualified Data.Text as T
Expand Down Expand Up @@ -146,7 +145,7 @@ data StaticDomEvent (a :: k)
-- | Static documents don't process events, so all handlers are equivalent
data StaticDomHandler (a :: k) (b :: k) = StaticDomHandler

data StaticEventSpec (er :: EventTag -> *) = StaticEventSpec deriving (Generic)
data StaticEventSpec (er :: EventTag -> Type) = StaticEventSpec deriving (Generic)

instance Default (StaticEventSpec er)

Expand Down Expand Up @@ -221,7 +220,7 @@ hoistIntMapWithKeyWithAdjust base f im0 im' = do
sample o
return (result0, result')

hoistDMapWithKeyWithAdjust :: forall (k :: * -> *) v v' t m p.
hoistDMapWithKeyWithAdjust :: forall (k :: Type -> Type) v v' t m p.
( Adjustable t m
, MonadHold t m
, PatchTarget (p k (Constant (Behavior t Builder))) ~ DMap k (Constant (Behavior t Builder))
Expand Down
1 change: 0 additions & 1 deletion reflex-dom-core/src/Reflex/Dom/Location.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import Control.Lens ((^.))
import Control.Monad ((>=>))
import Control.Monad.Fix (MonadFix)
import Data.Align (align)
import Data.Monoid
import Data.Text (Text)
import Data.These (These(..))
import qualified GHCJS.DOM as DOM
Expand Down
3 changes: 1 addition & 2 deletions reflex-dom-core/src/Reflex/Dom/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ import Reflex.Profiled
import Control.Concurrent
import Control.Lens
import Control.Monad
import Control.Monad.Reader hiding (forM, forM_, mapM, mapM_, sequence, sequence_)
import Control.Monad.Reader
import Control.Monad.Ref
import Data.ByteString (ByteString)
import Data.Dependent.Sum (DSum (..))
import Data.Foldable (for_)
import Data.IORef
import Data.Maybe
import Data.Monoid ((<>))
import Data.Text (Text)
import qualified Data.Text as T
import Data.Text.Encoding
Expand Down
1 change: 1 addition & 0 deletions reflex-dom-core/src/Reflex/Dom/Old.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifdef USE_TEMPLATE_HASKELL
{-# LANGUAGE TemplateHaskell #-}
#endif
{-# LANGUAGE TypeOperators #-}
module Reflex.Dom.Old
( MonadWidget
, El
Expand Down
Loading
Loading