Skip to content

Commit

Permalink
Get things building with ghc 9.8 for JS
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantrinkle committed Jun 4, 2024
1 parent 5d1dbde commit 4e8d6f0
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 75 deletions.
103 changes: 44 additions & 59 deletions reflex-dom-core/reflex-dom-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -67,58 +67,50 @@ flag gc-tests
library
hs-source-dirs: src
build-depends:
aeson >= 0.8 && < 2.2,
base >= 4.7 && < 4.15,
bifunctors >= 4.2 && < 6,
bimap >= 0.3 && < 0.5,
blaze-builder >= 0.4.1 && < 0.5,
bytestring == 0.10.*,
case-insensitive < 1.3,
commutative-semigroups >=0.1 && <0.2,
containers >= 0.6 && < 0.7,
constraints >= 0.9 && < 0.14,
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,
directory >= 1.2 && < 1.4,
exception-transformers == 0.4.*,
ghcjs-dom >= 0.9.1.0 && < 0.10,
jsaddle >= 0.9.0.0 && < 0.10,
aeson,
base,
bifunctors,
bimap,
blaze-builder,
bytestring,
case-insensitive,
commutative-semigroups,
containers,
constraints,
contravariant,
data-default,
dependent-map,
dependent-sum,
dependent-sum-template,
directory,
exception-transformers,
ghcjs-dom,
jsaddle,
-- keycode-0.2 has a bug on firefox
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,
random >= 1.1 && < 1.3,
ref-tf >= 0.4 && < 0.6,
reflex >= 0.8.2.1 && < 1,
semigroups >= 0.16 && < 0.20,
stm >= 2.4 && < 2.6,
text == 1.2.*,
transformers >= 0.3 && < 0.6,
network-uri >= 2.6.1 && < 2.7,
zenc == 0.1.*

if impl(ghcjs)
hs-source-dirs: src-ghcjs
build-depends:
ghcjs-base,
hashable >= 1.2 && < 1.4
else
hs-source-dirs: src-ghc
if !os(windows)
build-depends: unix == 2.7.*

if flag(split-these)
build-depends:
semialign >= 1 && < 1.3,
these >= 1 && < 1.3
else
build-depends:
these >= 0.4 && < 0.9
keycode,
lens,
monad-control,
mtl,
primitive,
random,
ref-tf,
reflex,
semigroups,
stm,
text,
transformers,
network-uri,
zenc,
ghcjs-base,
hashable,
semialign,
these,
dependent-sum-template,
template-haskell
other-extensions: TemplateHaskell
cpp-options: -DUSE_TEMPLATE_HASKELL

hs-source-dirs: src-ghcjs

exposed-modules:
Foreign.JavaScript.TH
Expand Down Expand Up @@ -153,6 +145,7 @@ library
Reflex.Dom.Xhr.Foreign
Reflex.Dom.Xhr.ResponseType
Reflex.Dom.Xhr.Exception
Reflex.Dom.Builder.Class.TH

default-language: Haskell98
ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans -fspecialise-aggressively
Expand All @@ -167,14 +160,6 @@ library
if flag(profile-reflex)
cpp-options: -DPROFILE_REFLEX

if flag(use-template-haskell)
build-depends:
dependent-sum-template >= 0.1 && < 0.2,
template-haskell >= 2.12.0 && < 2.17
other-extensions: TemplateHaskell
cpp-options: -DUSE_TEMPLATE_HASKELL
other-modules:
Reflex.Dom.Builder.Class.TH

test-suite hlint
build-depends:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Foreign.JavaScript.Internal.Utils

import GHCJS.Concurrent
import GHCJS.DOM.Types (JSM, JSVal, RequestAnimationFrameCallback (..))
import GHCJS.Foreign.Callback (releaseCallback)
import GHC.JS.Foreign.Callback (releaseCallback)

freeRequestAnimationFrameCallback :: RequestAnimationFrameCallback -> JSM ()
freeRequestAnimationFrameCallback (RequestAnimationFrameCallback cb) = releaseCallback cb
Expand Down
3 changes: 1 addition & 2 deletions reflex-dom-core/src/Foreign/JavaScript/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +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
import qualified GHCJS.Foreign.Callback as JS
import qualified GHCJS.Foreign.Callback.Internal (Callback (..))
import qualified GHC.JS.Foreign.Callback as JS
import qualified JavaScript.Array as JS
import qualified JavaScript.Array.Internal (SomeJSArray (..))
import qualified JavaScript.Object as JS
Expand Down
25 changes: 13 additions & 12 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 @@ -314,7 +315,7 @@ instance (Reflex t, er ~ EventResult, DomSpace s) => Default (InputElementConfig
, _inputElementConfig_setValue = Nothing
, _inputElementConfig_initialChecked = False
, _inputElementConfig_setChecked = Nothing
, _inputElementConfig_elementConfig = def
, _inputElementConfig_elementConfig = def :: ElementConfig EventResult t s
}

data InputElement er d t
Expand Down Expand Up @@ -352,7 +353,7 @@ instance (Reflex t, er ~ EventResult, DomSpace s) => Default (TextAreaElementCon
def = TextAreaElementConfig
{ _textAreaElementConfig_initialValue = ""
, _textAreaElementConfig_setValue = Nothing
, _textAreaElementConfig_elementConfig = def
, _textAreaElementConfig_elementConfig = def :: ElementConfig EventResult t s
}

data TextAreaElement er d t
Expand Down Expand Up @@ -413,7 +414,7 @@ instance (Reflex t, er ~ EventResult, DomSpace s) => Default (SelectElementConfi
def = SelectElementConfig
{ _selectElementConfig_initialValue = ""
, _selectElementConfig_setValue = Nothing
, _selectElementConfig_elementConfig = def
, _selectElementConfig_elementConfig = def :: ElementConfig EventResult t s
}

data SelectElement er d t = SelectElement
Expand All @@ -424,6 +425,15 @@ data SelectElement er d t = SelectElement
, _selectElement_raw :: RawSelectElement d
}

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
}

#ifdef USE_TEMPLATE_HASKELL
concat <$> mapM (uncurry makeLensesWithoutField)
[ (["_textNodeConfig_setContents"], ''TextNodeConfig)
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
2 changes: 2 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,6 +120,7 @@ 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.Primitive
import Control.Monad.Reader
Expand Down Expand Up @@ -206,6 +207,7 @@ import qualified Reflex.Patch.DMap as PatchDMap
import qualified Reflex.Patch.DMapWithMove as PatchDMapWithMove
import qualified Reflex.Patch.MapWithMove as PatchMapWithMove
import qualified Reflex.TriggerEvent.Base as TriggerEventT (askEvents)
import Control.Monad.Fix

#ifndef USE_TEMPLATE_HASKELL
import Data.Functor.Contravariant (phantom)
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 @@ -89,6 +89,7 @@ import qualified Data.Text as T
import Data.These
import Data.Traversable
import Prelude hiding (mapM, mapM_, sequence, sequence_)
import Control.Monad.Fix

-- | Breaks the given Map into pieces based on the given Set. Each piece will contain only keys that are less than the key of the piece, and greater than or equal to the key of the piece with the next-smaller key. There will be one additional piece containing all keys from the original Map that are larger or equal to the largest key in the Set.
-- Either k () is used instead of Maybe k so that the resulting map of pieces is sorted so that the additional piece has the largest key.
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

0 comments on commit 4e8d6f0

Please sign in to comment.