souplesse

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3278c7962c992511bd0182ce5ef10e3546990e87
parent c514c20e688ce3a17d8787978fb2fd7c822ee657
Author: Daniel Barlow <dan@telent.net>
Date:   Wed, 30 Oct 2024 14:25:54 +0000

add hlint and apply suggestions

Diffstat:
Mdefault.nix | 1+
Mlib/Track.hs | 8++++----
Mtests/UnitTest.hs | 4++--
3 files changed, 7 insertions(+), 6 deletions(-)

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