apply hlint suggestions

This commit is contained in:
Daniel Barlow 2024-10-31 17:22:07 +00:00
parent c3c31e52b4
commit ff4451cb6f
2 changed files with 7 additions and 13 deletions

View File

@ -63,9 +63,9 @@ elToPoint :: Cursor -> Either SomeException Point
elToPoint c =
case node c of
NodeElement (Element _ attrs _) ->
let lat = (listToMaybe $ attribute "lat" c) >>= asFloat
lon = (listToMaybe $ attribute "lon" c) >>= asFloat
ele = listToMaybe $ child c >>= element (gpxNS "ele") >>= child >>= content
let lat = listToMaybe (attribute "lat" c) >>= asFloat
lon = listToMaybe (attribute "lon" c) >>= asFloat
ele = listToMaybe (child c >>= element (gpxNS "ele") >>= child >>= content) >>= asFloat
ts =
listToMaybe (child c >>= element (gpxNS "time") >>= child >>= content)
>>= (Data.Time.ISO8601.parseISO8601 . Data.Text.unpack)
@ -85,15 +85,15 @@ elToPoint c =
then
Right $
Point
(Pos (fromJust lat) (fromJust lon) (ele >>= asFloat))
(Pos (fromJust lat) (fromJust lon) ele)
(fromJust ts)
(listToMaybe cadence >>= asInt)
(listToMaybe power >>= asInt)
(listToMaybe hr >>= asInt)
else Left (toException (BadFile "missing a required attribute"))
where
asFloat v = return (Data.Text.unpack v) >>= (readMaybe :: String -> Maybe Float)
asInt v = return (Data.Text.unpack v) >>= (readMaybe :: String -> Maybe Int)
asFloat v = (readMaybe :: String -> Maybe Float) (Data.Text.unpack v)
asInt v = (readMaybe :: String -> Maybe Int) (Data.Text.unpack v)
_ -> Left (toException (BadFile "did not find trkpt"))
getPoints :: Cursor -> Either SomeException [Point]

View File

@ -104,13 +104,7 @@ testMissingAttrs =
in TestCase $
assertBool
"failed to catch missing/malformed attribute"
( List.all
isLeft
( List.map
(\text -> Track.parse (wrapPoint text))
els
)
)
(List.all (isLeft . Track.parse . wrapPoint) els)
test2 =
TestList