Create Utils module for (|>) operator
For the past 3-4 Haskell projects on which I've worked, I've tried to habituate the usage of the (&) operator, but I find that -- as petty as it may sound -- I don't like the way that it looks, and I end up avoiding using it as a result. This time around, I'm aliasing it to (|>) (i.e. Elixir style), and I'm hoping to use it more.
This commit is contained in:
parent
191205acac
commit
90a521c78f
6 changed files with 16 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue