aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autotypes/autotypes.cabal1
-rw-r--r--backend/lib/ACMS/API/REST.hs4
-rw-r--r--backend/lib/ACMS/API/REST/Collection.hs6
-rw-r--r--common/common.cabal1
-rw-r--r--common/src/Collection.hs14
-rw-r--r--frontend/app/Schema.hs7
6 files changed, 15 insertions, 18 deletions
diff --git a/autotypes/autotypes.cabal b/autotypes/autotypes.cabal
index b812b94..5264f64 100644
--- a/autotypes/autotypes.cabal
+++ b/autotypes/autotypes.cabal
@@ -12,6 +12,7 @@ library
hs-source-dirs: src
default-language: Haskell2010
+ ghc-options: -fno-warn-x-partial
build-depends:
aeson,
aeson-pretty,
diff --git a/backend/lib/ACMS/API/REST.hs b/backend/lib/ACMS/API/REST.hs
index 44c307c..baf9adb 100644
--- a/backend/lib/ACMS/API/REST.hs
+++ b/backend/lib/ACMS/API/REST.hs
@@ -4,8 +4,10 @@ module ACMS.API.REST where
#ifndef ghcjs_HOST_OS
import Network.HTTP.Simple
+import Data.String (IsString(fromString))
#else
import Data.ByteString.Lazy.UTF8 qualified as LB
+import Data.ByteString qualified as B
import Data.Maybe
import Data.String
import JavaScript.Web.XMLHttpRequest
@@ -15,7 +17,6 @@ import Control.Monad.Catch (MonadThrow)
import Data.Aeson qualified as A
import Data.ByteString.Lazy.Char8 qualified as LB
import Data.Function ((&))
-import Data.String (IsString (fromString))
import Miso (JSM)
import Miso.String (MisoString)
@@ -50,7 +51,6 @@ instance APIMonad JSM where
fetch req = LB.fromStrict . getResponseBody <$> httpBS req
#ifdef ghcjs_HOST_OS
-
httpBS :: Request -> JSM (Response B.ByteString)
httpBS req = xhrByteString req
diff --git a/backend/lib/ACMS/API/REST/Collection.hs b/backend/lib/ACMS/API/REST/Collection.hs
index b3faf19..7eea23b 100644
--- a/backend/lib/ACMS/API/REST/Collection.hs
+++ b/backend/lib/ACMS/API/REST/Collection.hs
@@ -5,11 +5,7 @@ module ACMS.API.REST.Collection where
#ifndef ghcjs_HOST_OS
import Network.HTTP.Simple
#else
-import ACMS.API.REST (setRequestMethod, setRequestBodyLBS, getResponseBody)
-import Data.ByteString.Char8 qualified as B
-import Data.Maybe
-import JavaScript.Web.XMLHttpRequest
-import Miso.String qualified as J
+import ACMS.API.REST (setRequestMethod, setRequestBodyLBS)
#endif
import ACMS.API.REST (APIMonad, fetch, restRequest)
import Collection
diff --git a/common/common.cabal b/common/common.cabal
index 2c98a47..d67e5d6 100644
--- a/common/common.cabal
+++ b/common/common.cabal
@@ -18,5 +18,6 @@ library
build-depends:
aeson,
base,
+ miso,
split,
text
diff --git a/common/src/Collection.hs b/common/src/Collection.hs
index a23fd31..25cdec7 100644
--- a/common/src/Collection.hs
+++ b/common/src/Collection.hs
@@ -1,24 +1,26 @@
-{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}
+
module Collection where
-import Data.Text qualified as T
+import Miso.String (MisoString, toMisoString)
import Text.ParserCombinators.ReadP qualified as R
import Text.ParserCombinators.ReadPrec qualified as R
import Text.Read (Read (..))
-newtype Collection = Collection {name :: T.Text}
+newtype Collection = Collection {name :: MisoString}
deriving (Read, Eq, Show)
data CollectionItem = CollectionItem
{ collection :: Collection,
itemFileName :: FilePath
- } deriving (Eq)
+ }
+ deriving (Eq)
instance Read CollectionItem where
readPrec = R.lift $ do
- (Collection . T.pack -> collection) <- R.munch (/= '/')
+ (Collection . toMisoString -> collection) <- R.munch (/= '/')
_ <- R.string "/"
itemFileName <- do
itemFileName <- R.munch (liftA2 (&&) (/= '.') (/= '/'))
@@ -28,4 +30,4 @@ instance Read CollectionItem where
instance Show CollectionItem where
show (CollectionItem {collection = Collection cn, itemFileName}) =
- show (cn <> "/" <> T.pack itemFileName)
+ show (cn <> "/" <> toMisoString itemFileName)
diff --git a/frontend/app/Schema.hs b/frontend/app/Schema.hs
index b1618d3..13f37b3 100644
--- a/frontend/app/Schema.hs
+++ b/frontend/app/Schema.hs
@@ -6,9 +6,6 @@ module Schema
)
where
-#ifdef ghcjs_HOST_OS
-import Data.Text qualified as T
-#endif
import Control.Applicative ((<|>))
import Data.Aeson qualified as A
import Data.Aeson.Key qualified as AK
@@ -20,7 +17,7 @@ import Data.Scientific (fromFloatDigits)
import Data.Set qualified as S
import Form qualified as F
import Miso
-import Miso.String (MisoString, fromMisoString, intercalate, toMisoString)
+import Miso.String (MisoString, fromMisoString, toMisoString)
import Route
data Schema = Schema
@@ -45,7 +42,7 @@ instance A.FromJSON Schema where
#ifdef ghcjs_HOST_OS
instance A.FromJSONKey MisoString where
- parseJSON = fromMisoString @T.Text <$> parseJSON
+ fromJSONKey = fromMisoString <$> A.fromJSONKey
#endif
data Property