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