add Track.parseFile and call it from the main app
that's right, this is no longer a hello world app
This commit is contained in:
parent
b572e353b4
commit
a15346ae7a
@ -61,3 +61,6 @@ _Do not look below this line_
|
|||||||
* [done] need a real gpx file with namespace decls before we can parse power and stuff
|
* [done] need a real gpx file with namespace decls before we can parse power and stuff
|
||||||
* [done] tests seem to pass without <gpx> element?
|
* [done] tests seem to pass without <gpx> element?
|
||||||
* [done] stop returning bogus data when missing required elements (e.g. time)
|
* [done] stop returning bogus data when missing required elements (e.g. time)
|
||||||
|
* can we lose this "if isJust lat && isJust lon && isJust ts" wart?
|
||||||
|
* probably we should store points in a more efficient form than
|
||||||
|
a singly-linked list
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
|
import Control.Exception
|
||||||
|
import Track(parseFile)
|
||||||
|
import Data.List as List
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = putStrLn "Hello, Haskell!"
|
main = do
|
||||||
|
points <- Track.parseFile "track.gpx"
|
||||||
|
putStrLn ("loaded " ++ (show (List.length points)))
|
||||||
|
@ -10,6 +10,7 @@ module Track
|
|||||||
heartRate,
|
heartRate,
|
||||||
time,
|
time,
|
||||||
parse,
|
parse,
|
||||||
|
parseFile,
|
||||||
Track.length,
|
Track.length,
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@ -20,6 +21,7 @@ import Data.List as List
|
|||||||
import Data.List qualified
|
import Data.List qualified
|
||||||
import Data.Map as Map
|
import Data.Map as Map
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
import Data.Either
|
||||||
import Data.Text qualified
|
import Data.Text qualified
|
||||||
import Data.Text.Lazy as T
|
import Data.Text.Lazy as T
|
||||||
import Data.Time
|
import Data.Time
|
||||||
@ -110,3 +112,10 @@ parse str = do
|
|||||||
|
|
||||||
length :: Track -> Int
|
length :: Track -> Int
|
||||||
length = Data.List.length
|
length = Data.List.length
|
||||||
|
|
||||||
|
-- parseFile :: FilePath -> IO [Point]
|
||||||
|
parseFile name = do
|
||||||
|
gpx <- Text.XML.readFile def name
|
||||||
|
return $ case getPoints (fromDocument gpx) of
|
||||||
|
Left err -> []
|
||||||
|
Right points -> points
|
||||||
|
@ -68,7 +68,9 @@ executable souplesse
|
|||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
|
|
||||||
-- Other library packages from which modules are imported.
|
-- Other library packages from which modules are imported.
|
||||||
build-depends: base ^>=4.18.2.1
|
build-depends:
|
||||||
|
base ^>=4.18.2.1
|
||||||
|
, souplesse-lib
|
||||||
|
|
||||||
-- Directories containing source files.
|
-- Directories containing source files.
|
||||||
hs-source-dirs: app
|
hs-source-dirs: app
|
||||||
|
Loading…
Reference in New Issue
Block a user