@@ -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)
21import Data.String
22import Data.String
22import Data.Text as T
23import Data.Text as T
23import Data.UUID (UUID)
24import Data.UUID (UUID)
@@ -25,13 +26,11 @@ import qualified Data.UUID as UUID
25import qualified Data.UUID.V4 as UUID.V4
26import qualified Data.UUID.V4 as UUID.V4
26import GHC.TypeLits
27import GHC.TypeLits
27import Prelude as P
28import Prelude as P
29+import Test.QuickCheck
28import Text.ParserCombinators.ReadP
30import Text.ParserCombinators.ReadP
29import Web.HttpApiData
31import Web.HttpApiData
30import Web.PathPieces (PathPiece(..))
32import Web.PathPieces (PathPiece(..))
34−import Test.QuickCheck
35#ifdef USE_CASSAVA
34#ifdef USE_CASSAVA
36import Data.Csv as Csv hiding(Name)
35import Data.Csv as Csv hiding(Name)
@@ -39,7 +38,6 @@ import Data.Csv as Csv hiding(Name)
39import Database.PostgreSQL.Simple.FromField as PG (FromField)
38import Database.PostgreSQL.Simple.FromField as PG (FromField)
40import Database.PostgreSQL.Simple.ToField as PG (ToField)
39import Database.PostgreSQL.Simple.ToField as PG (ToField)
44#ifdef USE_FLAT
42#ifdef USE_FLAT
45import Flat as F
43import Flat as F
@@ -57,11 +55,9 @@ newtype Id t = Id { unId :: UUID }
57 , PG.ToField, PG.FromField
55 , PG.ToField, PG.FromField
60− , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey
58+ , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
62− , ToSchema, ToParamSchema
64− , FromHttpApiData, ToHttpApiData )
59+ , ToParamSchema, FromHttpApiData, ToHttpApiData
66type role Id nominal
62type role Id nominal
@@ -97,14 +93,12 @@ instance Data.Store.Store (Id s) where
97 size = Data.Store.ConstSize 16
93 size = Data.Store.ConstSize 16
101instance Arbitrary (Id t) where
96instance Arbitrary (Id t) where
102 arbitrary = fmap Id $ UUID.fromWords
97 arbitrary = fmap Id $ UUID.fromWords
103 <$> arbitrary
98 <$> arbitrary
104 <*> arbitrary
99 <*> arbitrary
105 <*> arbitrary
100 <*> arbitrary
106 <*> arbitrary
101 <*> arbitrary
109instance PathPiece (Id t) where
103instance PathPiece (Id t) where
110 fromPathPiece = coerce . UUID.fromText
104 fromPathPiece = coerce . UUID.fromText
@@ -159,11 +153,10 @@ newtype IntId t = IntId { unIntId :: Integer }
159#ifdef USE_STORE
153#ifdef USE_STORE
160 , Data.Store.Store
154 , Data.Store.Store
163− , ToSchema, ToParamSchema, Arbitrary
156+ , ToSchema, ToParamSchema, Arbitrary, FromJSON, ToJSON, NFData, Hashable
165− , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, FromHttpApiData
157+ , FromJSONKey, ToJSONKey, FromHttpApiData, ToHttpApiData, PathPiece, Num
166− , ToHttpApiData, PathPiece, Num, Integral, Real, Enum )
158+ , Integral, Real, Enum
168type role IntId nominal
161type role IntId nominal
@@ -210,11 +203,10 @@ newtype Name t = Name { unName :: Text }
210#ifdef USE_STORE
203#ifdef USE_STORE
211 , Data.Store.Store
204 , Data.Store.Store
214− , ToSchema, ToParamSchema
216− , FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, FromHttpApiData
206+ , ToSchema, ToParamSchema, FromJSON, ToJSON, NFData, Hashable, FromJSONKey
217− , ToHttpApiData, PathPiece, IsString, Semigroup, Monoid )
207+ , ToJSONKey, FromHttpApiData, ToHttpApiData, PathPiece, IsString, Semigroup
219type role Name nominal
211type role Name nominal
@@ -232,10 +224,8 @@ instance KnownSymbol s => Read (Name s) where
232 _ <- string ("Name-" <> symbolVal (Proxy @s) <> "-")
224 _ <- string ("Name-" <> symbolVal (Proxy @s) <> "-")
233 mkName <$> readS_to_P reads
225 mkName <$> readS_to_P reads
236instance Arbitrary (Name s) where
227instance Arbitrary (Name s) where
237 arbitrary = coerce . T.pack . getPrintableString <$> arbitrary
228 arbitrary = coerce . T.pack . getPrintableString <$> arbitrary
240-- | This is a more \"explicit\" 'coerce' specifically for 'Name'.
230-- | This is a more \"explicit\" 'coerce' specifically for 'Name'.
241-- You are forced to explicitly specify the phantom types you are converting
231-- You are forced to explicitly specify the phantom types you are converting