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