apply hlint suggestions
This commit is contained in:
parent
c3c31e52b4
commit
ff4451cb6f
12
lib/Track.hs
12
lib/Track.hs
@ -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]
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user