Skip to content

Commit 6f7c3c1

Browse files
committed
Toml codec instances for JSString
1 parent f9d2d59 commit 6f7c3c1

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

pub/functora-witch/functora-witch.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description:
88
build-type: Simple
99
category: Data
1010
license: MIT
11-
maintainer: Functora
11+
maintainer: [email protected]
1212

1313
source-repository head
1414
location:

pub/functora/functora.cabal

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ author: functora
33
build-type: Simple
44
category: Data
55
copyright: functora
6-
description: Custom prelude
76
extra-doc-files: CHANGELOG.md
87
license-file: LICENSE
98
license: BSD-3-Clause
109
maintainer: [email protected]
1110
name: functora
12-
synopsis: Custom prelude
11+
synopsis: A custom prelude and various libraries.
12+
description:
13+
A custom prelude and various libraries compatible with a wide range of GHC backends, including GHCJS and WASM.
14+
1315
version: 0.1.0.0
1416
homepage:
1517
https://github.com/functora/functora.github.io/tree/master/pub/functora
@@ -184,6 +186,9 @@ common pkg-cfg
184186
, optparse-applicative
185187
, tomland
186188

189+
if ((impl(ghcjs) || arch(javascript)) || os(wasi))
190+
build-depends: jsaddle
191+
187192
common pkg-web
188193
import: pkg
189194
hs-source-dirs: src/web

pub/functora/src/cfg/Functora/CfgOrphan.hs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE UndecidableInstances #-}
23
{-# OPTIONS_GHC -Wno-orphans #-}
34

@@ -16,6 +17,9 @@ import Functora.Prelude
1617
import qualified GHC.Generics as Generics
1718
import qualified Text.URI as URI
1819
import qualified Toml
20+
#if defined(__GHCJS__) || defined(ghcjs_HOST_OS) || defined(wasi_HOST_OS)
21+
import Data.JSString (JSString)
22+
#endif
1923

2024
genericTomlCodec ::
2125
( Generic a,
@@ -215,3 +219,21 @@ optsAeson =
215219
}
216220
where
217221
fmt = Toml.stripTypeNamePrefix $ Proxy @a
222+
223+
#if defined(__GHCJS__) || defined(ghcjs_HOST_OS) || defined(wasi_HOST_OS)
224+
instance Toml.HasCodec JSString where
225+
hasCodec =
226+
Toml.textBy (from @JSString @Text)
227+
$ pure . from @Text @JSString
228+
229+
instance Toml.HasItemCodec JSString where
230+
hasItemCodec =
231+
Left
232+
. Toml.mkAnyValueBiMap
233+
( \src -> do
234+
txt <- Toml.matchText src
235+
pure $ from @Text @JSString txt
236+
)
237+
$ Toml.Text
238+
. from @JSString @Text
239+
#endif

pub/functora/src/functora-ghcjs.cabal

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ author: functora
33
build-type: Simple
44
category: Data
55
copyright: functora
6-
description: Custom prelude
76
license: BSD-3-Clause
87
maintainer: [email protected]
98
name: functora-ghcjs
10-
synopsis: Custom prelude
9+
synopsis: A custom prelude and various libraries.
10+
description:
11+
A custom prelude and various libraries compatible with a wide range of GHC backends, including GHCJS and WASM.
12+
1113
version: 0.1.0.0
1214
homepage:
1315
https://github.com/functora/functora.github.io/tree/master/pub/functora

0 commit comments

Comments
 (0)