on master help sign in
id.cabal+61−56
since splitsnapshots
unifiedsplit
@@ -1,72 +1,77 @@
1−cabal-version: 2.4
1+cabal-version: 2.4
2+name: id
3+version: 0.2.0.0
4+license-file: LICENSE
2
5
3−name: id
6+flag cassava
4−version: 0.2.0.0
7+ description: Enable Postgresql support
5−license-file: LICENSE
8+ default: True
9+ manual: False
6
10
7−Flag cassava
11+flag postgres
8− Description: Enable Postgresql support
12+ description: Enable Postgresql support
9− Default: True
13+ default: True
10− Manual: False
14+ manual: False
11
15
16+flag flat
17+ description: Enable Flat serialization support
18+ default: True
19+ manual: False
12
20
13−Flag postgres
21+flag store
14− Description: Enable Postgresql support
22+ description: Enable Data.Store serialization support
15− Default: True
23+ default: False
16− Manual: False
24+ manual: False
17
25
18−Flag flat
26+flag uuid-impl
19− Description: Enable Flat serialization support
27+ description: Include some functions with extra dependencies.
20− Default: True
28+ Disable to reduce dependencies.
21− Manual: False
29+ default: True
22−
23−Flag store
24− Description: Enable Data.Store serialization support
25− Default: False
26− Manual: False
30+ manual: False
27
31
28library
32library
29− exposed-modules:
33+ exposed-modules: Data.Id
30− Data.Id
31− -- other-modules:
32− -- other-extensions:
33 build-depends:
34 build-depends:
34− aeson,
35+ , aeson >=1.0
35− base >=4.12 && <5,
36+ , base >=4.12 && <5
36− binary,
37+ , binary
37− deepseq,
38+ , deepseq
38− hashable,
39+ , hashable
39− http-api-data,
40+ , http-api-data
40− lens,
41+ , lens
41− path-pieces,
42+ , path-pieces
42− text,
43+ , text
43− uuid,
44+ , uuid-types
44− if !(impl(ghcjs) || arch(javascript))
45+ if flag(uuid-impl)
45− build-depends:
46− openapi3
47− , QuickCheck
48− cpp-options: -DBACKEND
49− if flag(postgres) && !(impl(ghcjs) || arch(javascript))
50 build-depends:
46 build-depends:
51− postgresql-simple
47+ , uuid >=1.3.9
52− cpp-options: -DUSE_POSTGRES
48+ cpp-options: -DUSE_UUID
49+
53− if flag(cassava) && !(impl(ghcjs) || arch(javascript))
50+ if !(impl(ghcjs) || arch(javascript) || arch(wasm32))
54 build-depends:
51 build-depends:
52+ , openapi3
53+ , QuickCheck
54+
55+ cpp-options: -DBACKEND
56+
57+ if (flag(postgres) && !(impl(ghcjs) || arch(javascript) || arch(wasm32)))
58+ build-depends: postgresql-simple
59+ cpp-options: -DUSE_POSTGRES
60+
61+ if (flag(cassava) && !(impl(ghcjs) || arch(javascript) || arch(wasm32)))
55− cassava
62+ build-depends: cassava
56− cpp-options: -DUSE_CASSAVA
63+ cpp-options: -DUSE_CASSAVA
64+
57 if flag(flat)
65 if flag(flat)
58− build-depends:
66+ build-depends: flat >=0.4
59− flat,
60− cpp-options: -DUSE_FLAT
67+ cpp-options: -DUSE_FLAT
68+
61 if flag(store)
69 if flag(store)
62− build-depends:
70+ build-depends: store
63− store,
64− cpp-options: -DUSE_STORE
71+ cpp-options: -DUSE_STORE
65
72
66− hs-source-dirs:
73+ hs-source-dirs: src
67− src
68− default-language:
74+ default-language: Haskell2010
69− Haskell2010
70 default-extensions:
75 default-extensions:
71 AllowAmbiguousTypes
76 AllowAmbiguousTypes
72 DeriveGeneric
77 DeriveGeneric
src/Data/Id.hs+11−4
@@ -4,9 +4,12 @@
4{-# OPTIONS_GHC -Wno-orphans #-}
4{-# OPTIONS_GHC -Wno-orphans #-}
5
5
6module Data.Id
6module Data.Id
7− ( Id, mkId, unId, randomId, unsafeIdTagConvert, coerceId, _Id, nilId
7+ ( Id, mkId, unId, unsafeIdTagConvert, coerceId, _Id, nilId
8 , IntId, mkIntId, unIntId, unsafeIntIdTagConvert, coerceIntId, _IntId
8 , IntId, mkIntId, unIntId, unsafeIntIdTagConvert, coerceIntId, _IntId
9 , Name, mkName, unName, unsafeNameTagConvert, coerceName, _Name
9 , Name, mkName, unName, unsafeNameTagConvert, coerceName, _Name
10+#ifdef USE_UUID
11+ , randomId
12+#endif
10 )
13 )
11 where
14 where
12
15
@@ -20,15 +23,17 @@ import Data.Data
20import Data.Hashable (Hashable)
23import Data.Hashable (Hashable)
21import Data.String
24import Data.String
22import Data.Text as T
25import Data.Text as T
23−import Data.UUID (UUID)
26+import Data.UUID.Types (UUID)
24−import qualified Data.UUID as UUID
27+import qualified Data.UUID.Types as UUID
25−import qualified Data.UUID.V4 as UUID.V4
26import GHC.TypeLits
28import GHC.TypeLits
27import Prelude as P
29import Prelude as P
28import Text.ParserCombinators.ReadP
30import Text.ParserCombinators.ReadP
29import Web.HttpApiData
31import Web.HttpApiData
30import Web.PathPieces (PathPiece(..))
32import Web.PathPieces (PathPiece(..))
31
33
34+#ifdef USE_UUID
35+import qualified Data.UUID.V4 as UUID.V4
36+#endif
32#ifdef BACKEND
37#ifdef BACKEND
33import Data.OpenApi
38import Data.OpenApi
34import Test.QuickCheck
39import Test.QuickCheck
@@ -71,9 +76,11 @@ mkId :: forall s. UUID -> Id s
71mkId = coerce
76mkId = coerce
72{-# INLINE mkId #-}
77{-# INLINE mkId #-}
73
78
79+#ifdef USE_UUID
74randomId :: forall s. IO (Id s)
80randomId :: forall s. IO (Id s)
75randomId = coerce <$> UUID.V4.nextRandom
81randomId = coerce <$> UUID.V4.nextRandom
76{-# INLINE randomId #-}
82{-# INLINE randomId #-}
83+#endif
77
84
78instance KnownSymbol s => Show (Id s) where
85instance KnownSymbol s => Show (Id s) where
79 show (Id v) = "Id-" <> symbolVal (Proxy @s) <> "-" <> P.show v
86 show (Id v) = "Id-" <> symbolVal (Proxy @s) <> "-" <> P.show v