Skip to content

Commit bf39bdf

Browse files
removed DerivingVia
1 parent 2b67a7b commit bf39bdf

File tree

3 files changed

+61
-41
lines changed

3 files changed

+61
-41
lines changed

.github/workflows/cabal.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
strategy:
2121
matrix:
2222
plan:
23+
- { ghc: "8.2.2", cabal: "2.0.1" }
24+
- { ghc: "8.4.4", cabal: "2.2.0.1" }
2325
- { ghc: "8.6.5", cabal: "2.4.0.1" }
2426
- { ghc: "8.8.3", cabal: "3.0.1" }
2527
- { ghc: "8.10.1", cabal: "3.2" }

quickjs-hs.cabal

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 1.12
22
name: quickjs-hs
3-
version: 0.1
3+
version: 0.1.2
44
homepage: https://github.com/goodlyrottenapple/quickjs-hs#readme
55
bug-reports: https://github.com/goodlyrottenapple/quickjs-hs/issues
66
author: Sam Balco
@@ -48,41 +48,48 @@ library
4848
, vector >=0.12 && <0.13
4949
default-language: Haskell2010
5050
include-dirs: quickjs
51-
-- Order matters for dynamic linking, see GHC#12152.
52-
-- To make both `cabal repl` and `stack ghci` work, we have to
53-
-- make "a.cpp" come alphabetically before "main.cpp".
5451
c-sources:
5552
quickjs/cutils.c
5653
, quickjs/libbf.c
57-
, quickjs/libregexp.c
5854
, quickjs/libunicode.c
55+
, quickjs/libregexp.c
5956
, quickjs/quickjs.h
6057
, quickjs/quickjs.c
6158
, quickjs/quickjs-libc.h
6259
, quickjs/quickjs-libc.c
60+
includes:
61+
quickjs/cutils.h
62+
, quickjs/libbf.h
63+
, quickjs/libunicode-table.h
64+
, quickjs/libunicode.h
65+
, quickjs/libregexp-opcode.h
66+
, quickjs/libregexp.h
67+
, quickjs/list.h
68+
, quickjs/quickjs-atom.h
69+
, quickjs/quickjs-opcode.h
6370
cc-options:
6471
-static -D_GNU_SOURCE
6572
-DCONFIG_VERSION="2020-07-05"
6673
-DCONFIG_BIGNUM
6774

6875
test-suite quickjs-hs-test
69-
type: exitcode-stdio-1.0
70-
main-is: Spec.hs
71-
hs-source-dirs: test
72-
other-modules: Paths_quickjs_hs
73-
default-language: Haskell2010
74-
ghc-options: -threaded -rtsopts -with-rtsopts=-N
75-
build-depends:
76-
base
77-
, quickjs-hs -any
78-
, aeson
79-
, exceptions
80-
, HUnit >=1.6.0.0 && <1.7
81-
, QuickCheck >=2.9 && <2.14
82-
, tasty >=1.0 && <1.3
83-
, tasty-hunit >=0.10 && <0.11
84-
, tasty-quickcheck >=0.9 && <0.11
85-
, text
86-
, unordered-containers
87-
, vector
76+
type: exitcode-stdio-1.0
77+
main-is: Spec.hs
78+
hs-source-dirs: test
79+
other-modules: Paths_quickjs_hs
80+
default-language: Haskell2010
81+
ghc-options: -threaded -rtsopts -with-rtsopts=-N
82+
build-depends:
83+
base
84+
, quickjs-hs -any
85+
, aeson
86+
, exceptions
87+
, HUnit >=1.6.0.0 && <1.7
88+
, QuickCheck >=2.9 && <2.14
89+
, tasty >=1.0 && <1.3
90+
, tasty-hunit >=0.10 && <0.11
91+
, tasty-quickcheck >=0.9 && <0.11
92+
, text
93+
, unordered-containers
94+
, vector
8895

src/Quickjs/Error.hs

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE ExistentialQuantification, DuplicateRecordFields, GeneralizedNewtypeDeriving, DerivingStrategies, DeriveGeneric, DerivingVia, RecordWildCards #-}
1+
{-# LANGUAGE ExistentialQuantification, DuplicateRecordFields, GeneralizedNewtypeDeriving, DerivingStrategies, DeriveGeneric, RecordWildCards #-}
22

33
module Quickjs.Error where
44
import Control.Exception (Exception(..), SomeException)
@@ -32,40 +32,40 @@ jsRuntimeExceptionFromException x = do
3232
cast a
3333

3434

35-
newtype JSRuntimeException e = JSRuntimeException e
36-
deriving Generic
37-
deriving newtype Show
38-
39-
instance (Show e, Typeable e) => Exception (JSRuntimeException e)
40-
where
41-
toException = jsRuntimeExceptionToException
42-
fromException = jsRuntimeExceptionFromException
43-
44-
4535

4636
instance ToJSON CLong where
4737
toJSON cl = toJSON (fromIntegral cl :: Integer)
4838

4939
data UnknownJSTag = UnknownJSTag {raw_tag :: !CLong}
5040
deriving (Generic, Typeable)
51-
deriving Exception via (JSRuntimeException UnknownJSTag)
41+
42+
instance Exception UnknownJSTag where
43+
toException = jsRuntimeExceptionToException
44+
fromException = jsRuntimeExceptionFromException
45+
5246

5347
instance Show UnknownJSTag where
5448
show UnknownJSTag{..} = "Uknown JS tag: " ++ show raw_tag
5549

5650

5751
data UnsupportedTypeTag = UnsupportedTypeTag {_tag :: JSTagEnum}
5852
deriving (Generic, Typeable)
59-
deriving Exception via (JSRuntimeException UnsupportedTypeTag)
6053

54+
instance Exception UnsupportedTypeTag where
55+
toException = jsRuntimeExceptionToException
56+
fromException = jsRuntimeExceptionFromException
6157

6258
instance Show UnsupportedTypeTag where
6359
show UnsupportedTypeTag{..} = "Unsupported type tag: " ++ show _tag
6460

6561

6662
data JSException = JSException {location :: Text, message :: Text}
6763
deriving (Generic, Typeable)
68-
deriving Exception via (JSRuntimeException JSException)
64+
65+
instance Exception JSException where
66+
toException = jsRuntimeExceptionToException
67+
fromException = jsRuntimeExceptionFromException
68+
6969

7070
instance Show JSException where
7171
show JSException{..} = "JS runtime threw an exception in " ++ toS location ++ ":\n=================\n" ++ toS message ++ "\n=================\n"
@@ -74,7 +74,11 @@ instance Show JSException where
7474

7575
data JSValueUndefined = JSValueUndefined {value :: Text}
7676
deriving (Generic, Typeable)
77-
deriving Exception via (JSRuntimeException JSValueUndefined)
77+
78+
instance Exception JSValueUndefined where
79+
toException = jsRuntimeExceptionToException
80+
fromException = jsRuntimeExceptionFromException
81+
7882

7983
instance Show JSValueUndefined where
8084
show JSValueUndefined{..} = "The JS value '" ++ toS value ++ "' is undefined."
@@ -87,15 +91,22 @@ data JSValueIncorrectType =
8791
, found :: JSTypeEnum
8892
}
8993
deriving (Generic, Typeable)
90-
deriving Exception via (JSRuntimeException JSValueIncorrectType)
94+
95+
instance Exception JSValueIncorrectType where
96+
toException = jsRuntimeExceptionToException
97+
fromException = jsRuntimeExceptionFromException
98+
9199

92100
instance Show JSValueIncorrectType where
93101
show JSValueIncorrectType{..} = "Type mismatch of the JS value '" ++ toS name ++ "'. Expected: " ++ show expected ++ ", found: " ++ show found
94102

95103

96104
data InternalError = InternalError { message :: Text }
97105
deriving (Generic, Typeable)
98-
deriving Exception via (JSRuntimeException InternalError)
106+
107+
instance Exception InternalError where
108+
toException = jsRuntimeExceptionToException
109+
fromException = jsRuntimeExceptionFromException
99110

100111
instance Show InternalError where
101112
show InternalError{..} = "Internal error occured:\n" ++ toS message

0 commit comments

Comments
 (0)