diff --git a/default.nix b/default.nix index 05ef899..a82412b 100644 --- a/default.nix +++ b/default.nix @@ -6,6 +6,7 @@ let pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages; [ cabal-install + hlint ]); }; in haskellEnv.overrideAttrs(o: { diff --git a/lib/Track.hs b/lib/Track.hs index b7964d7..b140be2 100644 --- a/lib/Track.hs +++ b/lib/Track.hs @@ -57,7 +57,7 @@ elToPoint c = ele = child c >>= element (Name "ele" (Just gpxNS) Nothing) >>= child >>= content in Point (Pos lat lon) (case ele of - e:[] -> Just $ asFloat e + [e] -> Just $ asFloat e _ -> Nothing) (UTCTime (toEnum 60631) 43200) (Just 0) @@ -66,7 +66,7 @@ elToPoint c = where asFloat v = (read (Data.Text.unpack v) :: Float) getAttr name = - case (Map.lookup name attrs) of + case Map.lookup name attrs of Just v -> asFloat v _ -> 0 _ -> mkPoint (Pos 0 0) @@ -80,7 +80,7 @@ getPoints c = element (ns "trk") >>= descendant >>= element (ns "trkpt") in - (List.map elToPoint trkpts) + List.map elToPoint trkpts parse :: String -> Either SomeException [Point] parse str = do @@ -88,4 +88,4 @@ parse str = do return (getPoints (fromDocument gpx)) length :: Track -> Int -length trk = Data.List.length trk +length = Data.List.length diff --git a/tests/UnitTest.hs b/tests/UnitTest.hs index b0e5a0d..1536646 100644 --- a/tests/UnitTest.hs +++ b/tests/UnitTest.hs @@ -28,11 +28,11 @@ xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/ wrap x = preamble ++ x ++ "" -onepoint = wrap $ +onepoint = wrap " \n\ \ \n\ \ " -onepointWithAttrs = wrap $ +onepointWithAttrs = wrap " \n\ \ \n\ \ 25.2\n\