From 0e7406f7aa538d67f9f8faf6fa63168b2883e674 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 4 Nov 2024 23:36:43 +0000 Subject: [PATCH] switch from Float to Double anticipating that the storage will prefer doubles --- lib/Track.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Track.hs b/lib/Track.hs index e66e4bc..987e186 100644 --- a/lib/Track.hs +++ b/lib/Track.hs @@ -32,7 +32,7 @@ import Text.Read (readMaybe) import Text.XML import Text.XML.Cursor as Cursor -data Pos = Pos Float Float (Maybe Float) deriving (Show, Eq) +data Pos = Pos Double Double (Maybe Double) deriving (Show, Eq) type Power = Maybe Int @@ -64,12 +64,12 @@ instance Exception BadFile elToPoint :: Cursor -> Either SomeException Point elToPoint c = - let lat = listToMaybe (attribute "lat" c) >>= asFloat - lon = listToMaybe (attribute "lon" c) >>= asFloat + let lat = listToMaybe (attribute "lat" c) >>= asDouble + lon = listToMaybe (attribute "lon" c) >>= asDouble ts = listToMaybe (child c >>= element (gpxNS "time") >>= child >>= content) >>= (Data.Time.ISO8601.parseISO8601 . Data.Text.unpack) - ele = listToMaybe (child c >>= element (gpxNS "ele") >>= child >>= content) >>= asFloat + ele = listToMaybe (child c >>= element (gpxNS "ele") >>= child >>= content) >>= asDouble gpxtpx = child c >>= element (gpxNS "extensions") @@ -93,7 +93,7 @@ elToPoint c = (listToMaybe hr >>= asInt) else Left (toException (BadFile "missing a required attribute")) where - asFloat v = (readMaybe :: String -> Maybe Float) (Data.Text.unpack v) + asDouble v = (readMaybe :: String -> Maybe Double) (Data.Text.unpack v) asInt v = (readMaybe :: String -> Maybe Int) (Data.Text.unpack v) getPoints :: Cursor -> Either SomeException [Point]