on master help sign in
Make this rel8able.
9ea9ea9Nick
id.cabal+9−2
@@ -5,16 +5,20 @@ version: 0.2.0.0
5license-file: LICENSE
5license-file: LICENSE
6
6
7Flag cassava
7Flag cassava
8− Description: Enable Postgresql support
8+ Description: Enable Cassava support
9 Default: True
9 Default: True
10 Manual: False
10 Manual: False
11
11
12−
13Flag postgres
12Flag postgres
14 Description: Enable Postgresql support
13 Description: Enable Postgresql support
15 Default: True
14 Default: True
16 Manual: False
15 Manual: False
17
16
17+Flag rel8
18+ Description: Enable Rel8 support
19+ Default: False
20+ Manual: False
21+
18Flag flat
22Flag flat
19 Description: Enable Flat serialization support
23 Description: Enable Flat serialization support
20 Default: True
24 Default: True
@@ -47,6 +51,9 @@ library
47 build-depends:
51 build-depends:
48 postgresql-simple
52 postgresql-simple
49 cpp-options: -DUSE_POSTGRES
53 cpp-options: -DUSE_POSTGRES
54+ if flag(rel8) && !impl(ghcjs)
55+ build-depends: rel8
56+ cpp-options: -DUSE_REL8
50 if flag(cassava) && !impl(ghcjs)
57 if flag(cassava) && !impl(ghcjs)
51 build-depends:
58 build-depends:
52 cassava
59 cassava
src/Data/Id.hs+15−2
@@ -18,6 +18,7 @@ import Data.Binary (Binary)
18import Data.Coerce (coerce)
18import Data.Coerce (coerce)
19import Data.Data
19import Data.Data
20import Data.Hashable (Hashable)
20import Data.Hashable (Hashable)
21+import Data.Int (Int64)
21import Data.OpenApi
22import Data.OpenApi
22import Data.String
23import Data.String
23import Data.Text as T
24import Data.Text as T
@@ -44,6 +45,9 @@ import Flat as F
44#ifdef USE_STORE
45#ifdef USE_STORE
45import qualified Data.Store
46import qualified Data.Store
46#endif
47#endif
48+#ifdef USE_REL8
49+import Rel8 (DBType(..))
50+#endif
47
51
48newtype Id t = Id { unId :: UUID }
52newtype Id t = Id { unId :: UUID }
49 deriving stock Data
53 deriving stock Data
@@ -53,6 +57,9 @@ newtype Id t = Id { unId :: UUID }
53#ifdef USE_POSTGRES
57#ifdef USE_POSTGRES
54 , PG.ToField, PG.FromField
58 , PG.ToField, PG.FromField
55#endif
59#endif
60+#ifdef USE_REL8
61+ , DBType
62+#endif
56#endif
63#endif
57 , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
64 , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
58 , ToParamSchema, FromHttpApiData, ToHttpApiData )
65 , ToParamSchema, FromHttpApiData, ToHttpApiData )
@@ -133,7 +140,7 @@ type family Ambiguous (a :: k) :: j where
133 Ambiguous x = x
140 Ambiguous x = x
134
141
135----------------- IntId
142----------------- IntId
136−newtype IntId t = IntId { unIntId :: Integer }
143+newtype IntId t = IntId { unIntId :: Int64 }
137 deriving stock Data
144 deriving stock Data
138 deriving newtype
145 deriving newtype
139 ( Eq, Ord, Binary
146 ( Eq, Ord, Binary
@@ -150,6 +157,9 @@ newtype IntId t = IntId { unIntId :: Integer }
150#ifdef USE_STORE
157#ifdef USE_STORE
151 , Data.Store.Store
158 , Data.Store.Store
152#endif
159#endif
160+#ifdef USE_REL8
161+ , DBType
162+#endif
153#endif
163#endif
154 , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
164 , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
155 , ToParamSchema, FromHttpApiData, ToHttpApiData, PathPiece, Arbitrary
165 , ToParamSchema, FromHttpApiData, ToHttpApiData, PathPiece, Arbitrary
@@ -160,7 +170,7 @@ type role IntId nominal
160makePrisms ''IntId
170makePrisms ''IntId
161
171
162mkIntId :: forall s. Integer -> IntId s
172mkIntId :: forall s. Integer -> IntId s
163−mkIntId = coerce
173+mkIntId = fromInteger
164{-# INLINE mkIntId #-}
174{-# INLINE mkIntId #-}
165
175
166instance KnownSymbol s => Show (IntId s) where
176instance KnownSymbol s => Show (IntId s) where
@@ -199,6 +209,9 @@ newtype Name t = Name { unName :: Text }
199#ifdef USE_STORE
209#ifdef USE_STORE
200 , Data.Store.Store
210 , Data.Store.Store
201#endif
211#endif
212+#ifdef USE_REL8
213+ , DBType
214+#endif
202#endif
215#endif
203 , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
216 , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
204 , ToParamSchema, FromHttpApiData, ToHttpApiData, PathPiece
217 , ToParamSchema, FromHttpApiData, ToHttpApiData, PathPiece
stack.yaml+8−1
@@ -1,4 +1,11 @@
1−resolver: lts-18.18
1+resolver: lts-19.31
2
2
3packages:
3packages:
4- .
4- .
5+
6+nix:
7+ packages: [ postgresql ]
8+
9+flags:
10+ id:
11+ rel8: true