about summary refs log tree commit diff
path: root/src/Types.hs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-01T11·29+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-01T11·29+0100
commit54eb29eae0398dd19f5fdaed278f29453b0b7e44 (patch)
treea1c43cbae4ea0185fc0cc4aba1a907b02e78dbe9 /src/Types.hs
parent83f4f8e9d669d91602520e1c12d2e8892120e4ba (diff)
Prefer RecordWildCard syntax for toFields functions
Refactoring old code to conform to the latest fashion.
Diffstat (limited to 'src/Types.hs')
-rw-r--r--src/Types.hs32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/Types.hs b/src/Types.hs
index 48c26caef0cc..7afb29276d98 100644
--- a/src/Types.hs
+++ b/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.
 accountFields :: Account -> (Username, HashedPassword, Email, Role, Maybe ProfilePicture)
-accountFields (Account { accountUsername
-                       , accountPassword
-                       , accountEmail
-                       , accountRole
-                       , accountProfilePicture
-                       })
+accountFields (Account {..})
   = ( accountUsername
     , accountPassword
     , accountEmail
@@ -247,10 +242,7 @@ data TripPK = TripPK
   } deriving (Eq, Show, Generic)
 
 tripPKFields :: TripPK -> (Username, Destination, Date)
-tripPKFields (TripPK{ tripPKUsername
-                    , tripPKDestination
-                    , tripPKStartDate
-                    })
+tripPKFields (TripPK{..})
   = (tripPKUsername, tripPKDestination, tripPKStartDate)
 
 instance FromJSON TripPK where
@@ -262,12 +254,7 @@ instance FromJSON TripPK where
 
 -- | Return the tuple representation of a Trip record for SQL.
 tripFields :: Trip -> (Username, Destination, Date, Date, Comment)
-tripFields (Trip{ tripUsername
-                , tripDestination
-                , tripStartDate
-                , tripEndDate
-                , tripComment
-                })
+tripFields (Trip{..})
   = ( tripUsername
     , tripDestination
     , tripStartDate
@@ -356,12 +343,13 @@ instance FromJSON CreateAccountRequest where
     createAccountRequestRole <- x .: "role"
     pure $ CreateAccountRequest{..}
 
-createAccountRequestFields :: CreateAccountRequest -> (Username, ClearTextPassword, Email, Role)
-createAccountRequestFields request =
-  ( createAccountRequestUsername request
-  , createAccountRequestPassword request
-  , createAccountRequestEmail request
-  , createAccountRequestRole request
+createAccountRequestFields :: CreateAccountRequest
+                           -> (Username, ClearTextPassword, Email, Role)
+createAccountRequestFields CreateAccountRequest{..} =
+  ( createAccountRequestUsername
+  , createAccountRequestPassword
+  , createAccountRequestEmail
+  , createAccountRequestRole
   )
 
 newtype SessionUUID = SessionUUID UUID.UUID