on master help sign in
Make this rel8able.
commit9ea9ea91262320950f46976d9e64312f9b54cfec authorNick <nick@typeable.io> dateMon 14 Nov 2022, 17:09 (4 years ago) parentab7e686
3 files changed+32−5
id.cabal+9−2 src/Data/Id.hs+15−2 stack.yaml+8−1
id.cabal+9−2
@@ -5,16 +5,20 @@ version: 0.2.0.0
55license-file: LICENSE
66
77Flag cassava
8− Description: Enable Postgresql support
8+ Description: Enable Cassava support
99 Default: True
1010 Manual: False
1111
12−
1312Flag postgres
1413 Description: Enable Postgresql support
1514 Default: True
1615 Manual: False
1716
17+Flag rel8
18+ Description: Enable Rel8 support
19+ Default: False
20+ Manual: False
21+
1822Flag flat
1923 Description: Enable Flat serialization support
2024 Default: True
@@ -47,6 +51,9 @@ library
4751 build-depends:
4852 postgresql-simple
4953 cpp-options: -DUSE_POSTGRES
54+ if flag(rel8) && !impl(ghcjs)
55+ build-depends: rel8
56+ cpp-options: -DUSE_REL8
5057 if flag(cassava) && !impl(ghcjs)
5158 build-depends:
5259 cassava
src/Data/Id.hs+15−2
@@ -18,6 +18,7 @@ import Data.Binary (Binary)
1818import Data.Coerce (coerce)
1919import Data.Data
2020import Data.Hashable (Hashable)
21+import Data.Int (Int64)
2122import Data.OpenApi
2223import Data.String
2324import Data.Text as T
@@ -44,6 +45,9 @@ import Flat as F
4445#ifdef USE_STORE
4546import qualified Data.Store
4647#endif
48+#ifdef USE_REL8
49+import Rel8 (DBType(..))
50+#endif
4751
4852newtype Id t = Id { unId :: UUID }
4953 deriving stock Data
@@ -53,6 +57,9 @@ newtype Id t = Id { unId :: UUID }
5357#ifdef USE_POSTGRES
5458 , PG.ToField, PG.FromField
5559#endif
60+#ifdef USE_REL8
61+ , DBType
62+#endif
5663#endif
5764 , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
5865 , ToParamSchema, FromHttpApiData, ToHttpApiData )
@@ -133,7 +140,7 @@ type family Ambiguous (a :: k) :: j where
133140 Ambiguous x = x
134141
135142----------------- IntId
136−newtype IntId t = IntId { unIntId :: Integer }
143+newtype IntId t = IntId { unIntId :: Int64 }
137144 deriving stock Data
138145 deriving newtype
139146 ( Eq, Ord, Binary
@@ -150,6 +157,9 @@ newtype IntId t = IntId { unIntId :: Integer }
150157#ifdef USE_STORE
151158 , Data.Store.Store
152159#endif
160+#ifdef USE_REL8
161+ , DBType
162+#endif
153163#endif
154164 , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
155165 , ToParamSchema, FromHttpApiData, ToHttpApiData, PathPiece, Arbitrary
@@ -160,7 +170,7 @@ type role IntId nominal
160170makePrisms ''IntId
161171
162172mkIntId :: forall s. Integer -> IntId s
163−mkIntId = coerce
173+mkIntId = fromInteger
164174{-# INLINE mkIntId #-}
165175
166176instance KnownSymbol s => Show (IntId s) where
@@ -199,6 +209,9 @@ newtype Name t = Name { unName :: Text }
199209#ifdef USE_STORE
200210 , Data.Store.Store
201211#endif
212+#ifdef USE_REL8
213+ , DBType
214+#endif
202215#endif
203216 , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
204217 , ToParamSchema, FromHttpApiData, ToHttpApiData, PathPiece
stack.yaml+8−1
@@ -1,4 +1,11 @@
1−resolver: lts-18.18
1+resolver: lts-19.31
22
33packages:
44- .
5+
6+nix:
7+ packages: [ postgresql ]
8+
9+flags:
10+ id:
11+ rel8: true