mirror of
https://github.com/redelmann/scat
synced 2025-01-10 06:34:20 +01:00
Lint.
This commit is contained in:
parent
a2eb523d5a
commit
b94c4fc159
@ -1,4 +1,4 @@
|
||||
{-# LANGUAGE OverloadedStrings, PatternGuards #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
-- | Password scatterer.
|
||||
module Main (main) where
|
||||
@ -148,7 +148,7 @@ getCode = do
|
||||
else return ""
|
||||
|
||||
|
||||
-- | Lists all the available schemas.
|
||||
-- | Lists all the available schemas.
|
||||
schemas :: [(String, Scat Schema)]
|
||||
schemas =
|
||||
[ ("safe", return safe)
|
||||
|
@ -63,7 +63,7 @@ instance Applicative Builder where
|
||||
pure x = Builder (\ n -> (n, x))
|
||||
f <*> x = Builder $ \ n ->
|
||||
let (n', g) = runBuilder f n
|
||||
in fmap g $ runBuilder x n'
|
||||
in g <$> runBuilder x n'
|
||||
|
||||
instance Monad Builder where
|
||||
return = pure
|
||||
@ -85,19 +85,19 @@ inRange (a, b) = fmap (+ a) $ lessThan $ b + 1 - a
|
||||
|
||||
-- | Returns a lower case letter.
|
||||
lower :: Builder Char
|
||||
lower = fmap (chr . (+ ord 'a')) $ lessThan 26
|
||||
lower = (chr . (+ ord 'a')) <$> lessThan 26
|
||||
|
||||
-- | Returns an upper case letter.
|
||||
upper :: Builder Char
|
||||
upper = fmap (chr . (+ ord 'A')) $ lessThan 26
|
||||
upper = (chr . (+ ord 'A')) <$> lessThan 26
|
||||
|
||||
-- | Returns an printable ascii char.
|
||||
ascii :: Builder Char
|
||||
ascii = fmap chr $ inRange (32, 126)
|
||||
ascii = chr <$> inRange (32, 126)
|
||||
|
||||
-- | Returns a digit.
|
||||
digit :: Builder Char
|
||||
digit = fmap chr $ inRange (48, 57)
|
||||
digit = chr <$> inRange (48, 57)
|
||||
|
||||
-- | Returns a letter.
|
||||
letter :: Builder Char
|
||||
|
@ -15,6 +15,7 @@ module Scat.Schemas
|
||||
, getBuilder
|
||||
|
||||
-- * Built-in schemas
|
||||
|
||||
-- ** Passwords
|
||||
, safe
|
||||
, alphanumeric
|
||||
@ -36,6 +37,7 @@ import Data.List (intercalate, (\\))
|
||||
import Data.Vector (Vector)
|
||||
import qualified Data.Vector as V
|
||||
import Data.Monoid
|
||||
import Control.Applicative
|
||||
import Control.Monad (replicateM)
|
||||
import System.IO
|
||||
|
||||
@ -186,5 +188,5 @@ fromFile :: FilePath -> (Vector String -> a) -> IO a
|
||||
fromFile fp bs = do
|
||||
fp' <- getDataFileName fp
|
||||
withFile fp' ReadMode $ \ h -> do
|
||||
!vect <- fmap (V.fromList . lines) $ hGetContents h
|
||||
!vect <- (V.fromList . lines) <$> hGetContents h
|
||||
return $ bs vect
|
||||
|
Loading…
Reference in New Issue
Block a user