Skip to content

Commit 6404d3c

Browse files
JoshMeredithymeister
authored andcommitted
Update GHCJS conditions to also support the GHC JavaScript backend
1 parent 3e54d3b commit 6404d3c

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

splitmix.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ library
8484
-- because it's valuable that splitmix and QuickCheck doesn't
8585
-- depend on about anything
8686

87-
if impl(ghcjs)
87+
if impl(ghcjs) || arch(javascript)
8888
cpp-options: -DSPLITMIX_INIT_GHCJS=1
8989

9090
else

src/System/Random/SplitMix/Init.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module System.Random.SplitMix.Init (
66

77
import Data.Word (Word64)
88

9-
#if defined(SPLITMIX_INIT_GHCJS) && __GHCJS__
9+
#if defined(SPLITMIX_INIT_GHCJS) && (__GHCJS__ || defined(javascript_HOST_ARCH))
1010

1111
import Data.Word (Word32)
1212

@@ -26,12 +26,17 @@ import System.CPUTime (cpuTimePrecision, getCPUTime)
2626

2727
initialSeed :: IO Word64
2828

29-
#if defined(SPLITMIX_INIT_GHCJS) && __GHCJS__
29+
#if defined(SPLITMIX_INIT_GHCJS) && (__GHCJS__ || defined(javascript_HOST_ARCH))
3030

3131
initialSeed = fmap fromIntegral initialSeedJS
3232

3333
foreign import javascript
34+
#if __GHCJS__
3435
"$r = Math.floor(Math.random()*0x100000000);"
36+
#else
37+
-- defined(javascript_HOST_ARCH)
38+
"(() => { return Math.floor(Math.random()*0x100000000); })"
39+
#endif
3540
initialSeedJS :: IO Word32
3641

3742
#else
@@ -56,3 +61,4 @@ initialSeed = do
5661

5762
#endif
5863
#endif
64+

0 commit comments

Comments
 (0)