Prefer RecordWildCard syntax for toFields functions
Refactoring old code to conform to the latest fashion.
This commit is contained in:
parent
83f4f8e9d6
commit
54eb29eae0
1 changed files with 10 additions and 22 deletions
32
src/Types.hs
32
src/Types.hs
|
@ -152,12 +152,7 @@ data Account = Account
|
||||||
|
|
||||||
-- | Return a tuple with all of the fields for an Account record to use for SQL.
|
-- | Return a tuple with all of the fields for an Account record to use for SQL.
|
||||||
accountFields :: Account -> (Username, HashedPassword, Email, Role, Maybe ProfilePicture)
|
accountFields :: Account -> (Username, HashedPassword, Email, Role, Maybe ProfilePicture)
|
||||||
accountFields (Account { accountUsername
|
accountFields (Account {..})
|
||||||
, accountPassword
|
|
||||||
, accountEmail
|
|
||||||
, accountRole
|
|
||||||
, accountProfilePicture
|
|
||||||
})
|
|
||||||
= ( accountUsername
|
= ( accountUsername
|
||||||
, accountPassword
|
, accountPassword
|
||||||
, accountEmail
|
, accountEmail
|
||||||
|
@ -247,10 +242,7 @@ data TripPK = TripPK
|
||||||
} deriving (Eq, Show, Generic)
|
} deriving (Eq, Show, Generic)
|
||||||
|
|
||||||
tripPKFields :: TripPK -> (Username, Destination, Date)
|
tripPKFields :: TripPK -> (Username, Destination, Date)
|
||||||
tripPKFields (TripPK{ tripPKUsername
|
tripPKFields (TripPK{..})
|
||||||
, tripPKDestination
|
|
||||||
, tripPKStartDate
|
|
||||||
})
|
|
||||||
= (tripPKUsername, tripPKDestination, tripPKStartDate)
|
= (tripPKUsername, tripPKDestination, tripPKStartDate)
|
||||||
|
|
||||||
instance FromJSON TripPK where
|
instance FromJSON TripPK where
|
||||||
|
@ -262,12 +254,7 @@ instance FromJSON TripPK where
|
||||||
|
|
||||||
-- | Return the tuple representation of a Trip record for SQL.
|
-- | Return the tuple representation of a Trip record for SQL.
|
||||||
tripFields :: Trip -> (Username, Destination, Date, Date, Comment)
|
tripFields :: Trip -> (Username, Destination, Date, Date, Comment)
|
||||||
tripFields (Trip{ tripUsername
|
tripFields (Trip{..})
|
||||||
, tripDestination
|
|
||||||
, tripStartDate
|
|
||||||
, tripEndDate
|
|
||||||
, tripComment
|
|
||||||
})
|
|
||||||
= ( tripUsername
|
= ( tripUsername
|
||||||
, tripDestination
|
, tripDestination
|
||||||
, tripStartDate
|
, tripStartDate
|
||||||
|
@ -356,12 +343,13 @@ instance FromJSON CreateAccountRequest where
|
||||||
createAccountRequestRole <- x .: "role"
|
createAccountRequestRole <- x .: "role"
|
||||||
pure $ CreateAccountRequest{..}
|
pure $ CreateAccountRequest{..}
|
||||||
|
|
||||||
createAccountRequestFields :: CreateAccountRequest -> (Username, ClearTextPassword, Email, Role)
|
createAccountRequestFields :: CreateAccountRequest
|
||||||
createAccountRequestFields request =
|
-> (Username, ClearTextPassword, Email, Role)
|
||||||
( createAccountRequestUsername request
|
createAccountRequestFields CreateAccountRequest{..} =
|
||||||
, createAccountRequestPassword request
|
( createAccountRequestUsername
|
||||||
, createAccountRequestEmail request
|
, createAccountRequestPassword
|
||||||
, createAccountRequestRole request
|
, createAccountRequestEmail
|
||||||
|
, createAccountRequestRole
|
||||||
)
|
)
|
||||||
|
|
||||||
newtype SessionUUID = SessionUUID UUID.UUID
|
newtype SessionUUID = SessionUUID UUID.UUID
|
||||||
|
|
Loading…
Reference in a new issue