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