add hlint and apply suggestions

This commit is contained in:
Daniel Barlow 2024-10-30 14:25:54 +00:00
parent c514c20e68
commit 3278c7962c
3 changed files with 7 additions and 6 deletions

View File

@ -6,6 +6,7 @@ let
pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages; pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages;
[ [
cabal-install cabal-install
hlint
]); ]);
}; };
in haskellEnv.overrideAttrs(o: { in haskellEnv.overrideAttrs(o: {

View File

@ -57,7 +57,7 @@ elToPoint c =
ele = child c >>= element (Name "ele" (Just gpxNS) Nothing) >>= child >>= content ele = child c >>= element (Name "ele" (Just gpxNS) Nothing) >>= child >>= content
in Point (Pos lat lon) in Point (Pos lat lon)
(case ele of (case ele of
e:[] -> Just $ asFloat e [e] -> Just $ asFloat e
_ -> Nothing) _ -> Nothing)
(UTCTime (toEnum 60631) 43200) (UTCTime (toEnum 60631) 43200)
(Just 0) (Just 0)
@ -66,7 +66,7 @@ elToPoint c =
where where
asFloat v = (read (Data.Text.unpack v) :: Float) asFloat v = (read (Data.Text.unpack v) :: Float)
getAttr name = getAttr name =
case (Map.lookup name attrs) of case Map.lookup name attrs of
Just v -> asFloat v Just v -> asFloat v
_ -> 0 _ -> 0
_ -> mkPoint (Pos 0 0) _ -> mkPoint (Pos 0 0)
@ -80,7 +80,7 @@ getPoints c =
element (ns "trk") >>= descendant >>= element (ns "trk") >>= descendant >>=
element (ns "trkpt") element (ns "trkpt")
in in
(List.map elToPoint trkpts) List.map elToPoint trkpts
parse :: String -> Either SomeException [Point] parse :: String -> Either SomeException [Point]
parse str = do parse str = do
@ -88,4 +88,4 @@ parse str = do
return (getPoints (fromDocument gpx)) return (getPoints (fromDocument gpx))
length :: Track -> Int length :: Track -> Int
length trk = Data.List.length trk length = Data.List.length

View File

@ -28,11 +28,11 @@ xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/
wrap x = preamble ++ x ++ "</gpx>" wrap x = preamble ++ x ++ "</gpx>"
onepoint = wrap $ onepoint = wrap
"<trk> <trkseg> \n\ "<trk> <trkseg> \n\
\<trkpt lat=\"51\" lon=\"-0.1\"> </trkpt> \n\ \<trkpt lat=\"51\" lon=\"-0.1\"> </trkpt> \n\
\</trkseg> </trk>" \</trkseg> </trk>"
onepointWithAttrs = wrap $ onepointWithAttrs = wrap
"<trk> <trkseg> \n\ "<trk> <trkseg> \n\
\<trkpt lat=\"51\" lon=\"-0.1\"> \n\ \<trkpt lat=\"51\" lon=\"-0.1\"> \n\
\ <ele>25.2</ele>\n\ \ <ele>25.2</ele>\n\