Apply hlint suggestions

This commit is contained in:
Dimitri Lozeve 2018-01-17 19:46:55 +00:00
parent 15722908f4
commit 0c107d563e
2 changed files with 5 additions and 7 deletions

View file

@ -49,7 +49,7 @@ listLSystemsParser = infoOption (printList lsystems)
splitOn :: Char -> String -> [String]
splitOn c s = case dropWhile (== c) s of
"" -> []
s' -> w:(splitOn c s'')
s' -> w : splitOn c s''
where (w, s'') = break (== c) s'
colorParser :: Parser Color
@ -60,7 +60,7 @@ colorParser = option (eitherReader readRGB)
<> showDefault
<> value white
<> metavar "R,G,B")
where readRGB s = do
where readRGB s =
case mapM readEitherSafe $ splitOn ',' s of
Right (r:g:b:a:_) -> Right $ makeColorI r g b a
Right (r:g:b:_) -> Right $ makeColorI r g b 255

View file

@ -45,10 +45,8 @@ iterateLSystem 0 lsystem = lsystem
iterateLSystem n lsystem | n < 0 = iterateLSystem (-n) lsystem
iterateLSystem n (LSystem na a ax r ang dist rep) =
iterateLSystem (n-1) $ LSystem na a ax' r ang dist rep
where ax' = concat $ map f ax
f x = case lookup x r of
Just xs -> xs
Nothing -> [x]
where ax' = concatMap f ax
f x = fromMaybe [x] (lookup x r)
-- | Generate a set of instructions from an L-system
instructions :: Eq a => LSystem a -> [Instruction]
@ -71,7 +69,7 @@ turtle angle distance = go 90 (Line [(0,0)]) (Pictures []) []
TurnLeft -> go (theta - angle) (Line path) (Pictures ps) stack xs
Push -> go theta (Line path) (Pictures ps) ((head path, theta):stack) xs
Pop -> let (pos, theta'):t = stack in
go theta' (Line [pos]) (Pictures ((Line path):ps)) t xs
go theta' (Line [pos]) (Pictures (Line path : ps)) t xs
Stay -> go theta (Line path) (Pictures ps) stack xs
where
(px, py) = head path