about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/Accounts.hs1
-rw-r--r--src/App.hs2
-rw-r--r--src/Sessions.hs1
-rw-r--r--src/Trips.hs6
-rw-r--r--src/Types.hs8
-rw-r--r--src/Utils.hs8
6 files changed, 16 insertions, 10 deletions
diff --git a/src/Accounts.hs b/src/Accounts.hs
index bdc0bf64d432..c18a599a30a7 100644
--- a/src/Accounts.hs
+++ b/src/Accounts.hs
@@ -2,7 +2,6 @@
 --------------------------------------------------------------------------------
 module Accounts where
 --------------------------------------------------------------------------------
-import Data.Function ((&))
 import Database.SQLite.Simple
 
 import qualified Types as T
diff --git a/src/App.hs b/src/App.hs
index 5160f3627560..929d16520c34 100644
--- a/src/App.hs
+++ b/src/App.hs
@@ -7,12 +7,12 @@ module App where
 --------------------------------------------------------------------------------
 import Control.Exception (throwIO)
 import Control.Monad.IO.Class (liftIO)
-import Data.Function ((&))
 import Data.String.Conversions (cs)
 import Data.Text (Text)
 import Network.Wai.Handler.Warp as Warp
 import Servant
 import API
+import Utils
 
 import qualified Crypto.KDF.BCrypt as BC
 import qualified Data.Text.Encoding as TE
diff --git a/src/Sessions.hs b/src/Sessions.hs
index 238a70b6eb8a..1d3f0d6e88fa 100644
--- a/src/Sessions.hs
+++ b/src/Sessions.hs
@@ -3,7 +3,6 @@
 --------------------------------------------------------------------------------
 module Sessions where
 --------------------------------------------------------------------------------
-import Data.Function ((&))
 import Database.SQLite.Simple
 
 import qualified Data.Time.Clock as Clock
diff --git a/src/Trips.hs b/src/Trips.hs
index 0b395f8bcfe8..0d805cbe8603 100644
--- a/src/Trips.hs
+++ b/src/Trips.hs
@@ -2,8 +2,8 @@
 --------------------------------------------------------------------------------
 module Trips where
 --------------------------------------------------------------------------------
-import Data.Function ((&))
 import Database.SQLite.Simple
+import Utils
 
 import qualified Types as T
 --------------------------------------------------------------------------------
@@ -12,14 +12,14 @@ import qualified Types as T
 create :: FilePath -> T.Trip -> IO ()
 create dbFile trip = withConnection dbFile $ \conn ->
   execute conn "INSERT INTO Trips (username,destination,startDate,endDate,comment) VALUES (?,?,?,?,?)"
-    (trip & T.tripFields)
+    (trip |> T.tripFields)
 
 -- | Delete a trip from `dbFile` using its `tripPK` Primary Key.
 delete :: FilePath -> T.TripPK -> IO ()
 delete dbFile tripPK =
   withConnection dbFile $ \conn -> do
     execute conn "DELETE FROM Trips WHERE username = ? AND destination = ? and startDate = ?"
-      (tripPK & T.tripPKFields)
+      (tripPK |> T.tripPKFields)
 
 -- | Return a list of all of the trips in `dbFile`.
 list :: FilePath -> IO [T.Trip]
diff --git a/src/Types.hs b/src/Types.hs
index 6a474a5094bd..96cfae2c28cf 100644
--- a/src/Types.hs
+++ b/src/Types.hs
@@ -6,7 +6,7 @@
 module Types where
 --------------------------------------------------------------------------------
 import Data.Aeson
-import Data.Function ((&))
+import Utils
 import Data.Text
 import Data.Typeable
 import Database.SQLite.Simple
@@ -52,7 +52,7 @@ instance ToField HashedPassword where
 instance FromField HashedPassword where
   fromField field =
     case fieldData field of
-      (SQLText x) -> x & TE.encodeUtf8 & HashedPassword & Ok
+      (SQLText x) -> x |> TE.encodeUtf8 |> HashedPassword |> Ok
       _ -> returnError ConversionFailed field ""
 
 newtype ClearTextPassword = ClearTextPassword Text
@@ -314,10 +314,10 @@ instance FromJSON AccountCredentials where
                            }
 
 
--- -- | Hash password `x`.
+-- | Hash password `x`.
 hashPassword :: (MonadRandom m) => ClearTextPassword -> m HashedPassword
 hashPassword (ClearTextPassword x) = do
-  hashed <- BC.hashPassword 12 (x & unpack & B.pack)
+  hashed <- BC.hashPassword 12 (x |> unpack |> B.pack)
   pure $ HashedPassword hashed
 
 data CreateAccountRequest = CreateAccountRequest
diff --git a/src/Utils.hs b/src/Utils.hs
new file mode 100644
index 000000000000..78ee93ec95de
--- /dev/null
+++ b/src/Utils.hs
@@ -0,0 +1,8 @@
+--------------------------------------------------------------------------------
+module Utils where
+--------------------------------------------------------------------------------
+import Data.Function ((&))
+--------------------------------------------------------------------------------
+
+-- | Prefer this operator to the ampersand for stylistic reasons.
+(|>) = (&)