packages feed

casr-logbook-reports (empty) → 0.0.1

raw patch · 9 files changed

+530/−0 lines, 9 filesdep +QuickCheckdep +basedep +casr-logbookbuild-type:Customsetup-changed

Dependencies added: QuickCheck, base, casr-logbook, containers, directory, doctest, filepath, lens, template-haskell, time

Files

+ LICENSE view
@@ -0,0 +1,27 @@+Copyright 2016 Tony Morris+All rights reserved.++Redistribution and use in source and binary forms, with or without modification,+are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+list of conditions, the following disclaimer and the following SHA-512 checksum.++2. Redistributions in binary form must reproduce the above copyright notice,+this list of conditions, the following disclaimer and the following SHA-512+checksum in the documentation and/or other materials provided with the+distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.++THIS SOFTWARE IS PROVIDED WITH A SHA-512 CHECKSUM.+ecdfdf543fd166b13b76b11e0b010e00d693028771880ffd8f9252ae0b8ac42bddf8eb7a23c21c86a3b50039d642ad9eeb7e8a0e82f6a345f60feb4a54808362
+ Setup.lhs view
@@ -0,0 +1,44 @@+#!/usr/bin/env runhaskell+\begin{code}+{-# OPTIONS_GHC -Wall #-}+module Main (main) where++import Data.List ( nub )+import Data.Version ( showVersion )+import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )+import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )+import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )+import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )+import Distribution.Simple.BuildPaths ( autogenModulesDir )+import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )+import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )+import Distribution.Verbosity ( Verbosity )+import System.FilePath ( (</>) )++main :: IO ()+main = defaultMainWithHooks simpleUserHooks+  { buildHook = \pkg lbi hooks flags -> do+     generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi+     buildHook simpleUserHooks pkg lbi hooks flags+  }++generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()+generateBuildModule verbosity pkg lbi = do+  let dir = autogenModulesDir lbi+  createDirectoryIfMissingVerbose verbosity True dir+  withLibLBI pkg lbi $ \_ libcfg -> do+    withTestLBI pkg lbi $ \suite suitecfg -> do+      rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines+        [ "module Build_" ++ testName suite ++ " where"+        , "deps :: [String]"+        , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))+        ]+  where+    formatdeps = map (formatone . snd)+    formatone p = case packageName p of+      PackageName n -> n ++ "-" ++ showVersion (packageVersion p)++testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]+testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys++\end{code}
+ casr-logbook-reports.cabal view
@@ -0,0 +1,80 @@+name:               casr-logbook-reports+version:            0.0.1+license:            OtherLicense+license-file:       LICENSE+author:             Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>+maintainer:         Tony Morris+copyright:          Copyright (C) 2016 Tony Morris+synopsis:           CASR 61.345 logbook (casr-logbook) reports.+category:           Aviation+description:        +  <<https://i.imgur.com/p6LT40r.png>>+  .+  CASR 61.345 Pilot Personal Logbook reports+  .+  <<https://i.imgur.com/Lfhcmtg.png>>++homepage:           https://github.com/tonymorris/casr-logbook-reports+bug-reports:        https://github.com/tonymorris/casr-logbook-reports/issues+cabal-version:      >= 1.10+build-type:         Custom+extra-source-files: changelog++source-repository   head+  type:             git+  location:         git@github.com:tonymorris/casr-logbook-reports.git++flag                small_base+  description:      Choose the new, split-up base package.++library+  default-language:+                    Haskell2010++  build-depends:+                    base < 5 && >= 4.8+                    , casr-logbook >= 0.1.3 && < 0.2+                    , lens >= 4.1 && < 5+                    , time < 2 && >= 1.5+                    , containers < 0.6 && >= 0.4+                    +  ghc-options:+                    -Wall++  default-extensions:+                    NoImplicitPrelude++  hs-source-dirs:+                    src++  exposed-modules:+                    Data.Aviation.Casr.Logbook.Reports+                    Data.Aviation.Casr.Logbook.Reports.FlightTimeReport+                    Data.Aviation.Casr.Logbook.Reports.SimulatorTimeReport+                    Data.Aviation.Casr.Logbook.Reports.TakeOffLanding90+++test-suite doctests+  type:+                    exitcode-stdio-1.0++  main-is:+                    doctests.hs++  default-language:+                    Haskell2010++  build-depends:+                    base < 5 && >= 3+                    , doctest >= 0.9.7+                    , filepath >= 1.3+                    , directory >= 1.1+                    , QuickCheck >= 2.0+                    , template-haskell >= 2.8++  ghc-options:+                    -Wall+                    -threaded++  hs-source-dirs:+                    test
+ changelog view
@@ -0,0 +1,4 @@+0.0.1++* Initial release+
+ src/Data/Aviation/Casr/Logbook/Reports.hs view
@@ -0,0 +1,7 @@+module Data.Aviation.Casr.Logbook.Reports(+  module R+) where++import Data.Aviation.Casr.Logbook.Reports.FlightTimeReport as R+import Data.Aviation.Casr.Logbook.Reports.SimulatorTimeReport as R+import Data.Aviation.Casr.Logbook.Reports.TakeOffLanding90 as R
+ src/Data/Aviation/Casr/Logbook/Reports/FlightTimeReport.hs view
@@ -0,0 +1,242 @@+{-# LANGUAGE TemplateHaskell #-}++module Data.Aviation.Casr.Logbook.Reports.FlightTimeReport(+  FlightTimeReport(..)+, HasFlightTimeReport(..)+, singleFlightTimeReport+, getFlightTimeReport+) where++import Control.Category((.))+import Control.Lens(makeClassy, (^.))+import Data.Aviation.Casr.Logbook+  (+    TimeAmount+  , Aviator+  , Logbook(Logbook)+  , Command(ICUS, Dual, InCommand)+  , Engine(Single, Multi)+  , Entry(AircraftFlightEntry)+  , Entries(Entries)+  , aircraftEngine+  , aircraftRegistration+  , aircraftType+  , instrumentflightTime+  , getInstructingPic+  , flightaircraft+  , command+  , daynight+  , dayDayNight+  , nightDayNight+  , totalDayNight+  )+import Data.Eq(Eq)+import Data.Foldable(foldl')+import Data.Int(Int)+import qualified Data.Map as Map(unionWith, singleton, empty)+import Data.Map(Map)+import Data.Maybe(Maybe(Just, Nothing))+import Data.Monoid(Monoid(mappend, mempty))+import Data.Ord(Ord)+import Data.String(String)+import Prelude(Show, (+))++data FlightTimeReport =+  FlightTimeReport {+    _flightsTotal ::+      Int+  , _hoursTotal ::+      TimeAmount +  , _hoursTotalICUS ::+      TimeAmount +  , _hoursTotalDual ::+      TimeAmount +  , _hoursTotalInCommand ::+      TimeAmount +  , _hoursInAircraftType ::+      Map String (TimeAmount, TimeAmount, TimeAmount, TimeAmount)+  , _hoursInAircraftRegistration ::+      Map String (TimeAmount, TimeAmount, TimeAmount, TimeAmount)+  , _hoursSingleEngine ::+      TimeAmount +  , _hoursSingleEngineICUS ::+      TimeAmount +  , _hoursSingleEngineDual :: +      TimeAmount +  , _hoursSingleEngineInCommand ::+      TimeAmount +  , _hoursMultiEngine ::+      TimeAmount +  , _hoursMultiEngineICUS ::+      TimeAmount +  , _hoursMultiEngineDual ::+      TimeAmount +  , _hoursMultiEngineInCommand ::+      TimeAmount +  , _hoursDay ::+      TimeAmount +  , _hoursDayICUS ::+      TimeAmount +  , _hoursDayDual ::+      TimeAmount +  , _hoursDayInCommand ::+      TimeAmount +  , _hoursNight ::+      TimeAmount +  , _hoursNightICUS ::+      TimeAmount +  , _hoursNightDual ::+      TimeAmount +  , _hoursNightInCommand ::+      TimeAmount +  , _hoursWithPiC ::+      Map Aviator TimeAmount+  , _hoursInstrument ::+      TimeAmount +  } deriving (Eq, Ord, Show)++makeClassy ''FlightTimeReport++instance Monoid FlightTimeReport where+  mempty =+    FlightTimeReport+      0+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+      mempty+  FlightTimeReport ft1 tl1 tli1 tld1 tlc1 tp1 rg1 se1 sei1 sed1 sec1 me1 mei1 med1 mec1 dy1 dyi1 dyd1 dyc1 nt1 nti1 ntd1 ntc1 wpc1 is1 `mappend` FlightTimeReport ft2 tl2 tli2 tld2 tlc2 tp2 rg2 se2 sei2 sed2 sec2 me2 mei2 med2 mec2 dy2 dyi2 dyd2 dyc2 nt2 nti2 ntd2 ntc2 wpc2 is2 =+    FlightTimeReport+      (ft1 + ft2)+      (tl1 `mappend` tl2)+      (tli1 `mappend` tli2)+      (tld1 `mappend` tld2)+      (tlc1 `mappend` tlc2)+      (Map.unionWith mappend tp1 tp2)+      (Map.unionWith mappend rg1 rg2)+      (se1 `mappend` se2)+      (sei1 `mappend` sei2)+      (sed1 `mappend` sed2)+      (sec1 `mappend` sec2)+      (me1 `mappend` me2)+      (mei1 `mappend` mei2)+      (med1 `mappend` med2)+      (mec1 `mappend` mec2)+      (dy1 `mappend` dy2)+      (dyi1 `mappend` dyi2)+      (dyd1 `mappend` dyd2)+      (dyc1 `mappend` dyc2)+      (nt1 `mappend` nt2)+      (nti1 `mappend` nti2)+      (ntd1 `mappend` ntd2)+      (ntc1 `mappend` ntc2)+      (Map.unionWith mappend wpc1 wpc2)+      (is1 `mappend` is2)++singleFlightTimeReport ::+  Entry a b c d+  -> FlightTimeReport+singleFlightTimeReport (AircraftFlightEntry fl _) =+  let hoursdaynight = totalDayNight (fl ^. daynight)+      icus x =+        case fl ^. command of+          ICUS _ ->+            x+          Dual _ ->+            mempty+          InCommand ->+            mempty+      dual x =+        case fl ^. command of+          ICUS _ ->+            mempty+          Dual _ ->+            x+          InCommand ->+            mempty            +      comd x =+        case fl ^. command of+          ICUS _ ->+            mempty+          Dual _ ->+            mempty+          InCommand ->+            x+      hoursmap k =+        Map.singleton k (hoursdaynight, (icus hoursdaynight), (dual hoursdaynight), (comd hoursdaynight))+      singleengine x =+        case fl ^. flightaircraft . aircraftEngine of+          Single ->+            x+          Multi ->+            mempty+      multiengine x =+        case fl ^. flightaircraft . aircraftEngine of+          Single ->+            mempty+          Multi ->+            x+      totalhoursday =+        fl ^. daynight . dayDayNight+      totalhoursnight =+        fl ^. daynight . nightDayNight+      pic x =+        case getInstructingPic (fl ^. command) of+          Just a ->+            Map.singleton a x+          Nothing ->+            Map.empty+  in  FlightTimeReport+        1+        hoursdaynight+        (icus hoursdaynight)+        (dual hoursdaynight)+        (comd hoursdaynight)+        (hoursmap (fl ^. flightaircraft . aircraftType))+        (hoursmap (fl ^. flightaircraft . aircraftRegistration))+        (singleengine hoursdaynight)+        (singleengine (icus hoursdaynight))+        (singleengine (dual hoursdaynight))+        (singleengine (comd hoursdaynight))+        (multiengine hoursdaynight)+        (multiengine (icus hoursdaynight))+        (multiengine (dual hoursdaynight))+        (multiengine (comd hoursdaynight))+        totalhoursday+        (icus totalhoursday)+        (dual totalhoursday)+        (comd totalhoursday)+        totalhoursnight+        (icus totalhoursnight)+        (dual totalhoursnight)+        (comd totalhoursnight)+        (pic hoursdaynight)+        (fl ^. instrumentflightTime)+singleFlightTimeReport _ =+  mempty++getFlightTimeReport ::+  Logbook a b c d+  -> FlightTimeReport+getFlightTimeReport (Logbook _ (Entries es)) =+  foldl' (\a -> mappend a . singleFlightTimeReport) mempty es
+ src/Data/Aviation/Casr/Logbook/Reports/SimulatorTimeReport.hs view
@@ -0,0 +1,60 @@+{-# LANGUAGE TemplateHaskell #-}++module Data.Aviation.Casr.Logbook.Reports.SimulatorTimeReport(+  SimulatorTimeReport(..)+, HasSimulatorTimeReport(..)+, singleSimulatorTimeReport+, getSimulatorTimeReport+) where++import Control.Category((.))+import Control.Lens(makeClassy, (^.))+import Data.Aviation.Casr.Logbook+  (+    TimeAmount+  , Logbook(Logbook)+  , Entry(SimulatorFlightEntry)+  , Entries(Entries)+  , simulatorTime+  , instrumentsimulatorTime+  )+import Data.Eq(Eq)+import Data.Foldable(foldl')+import Data.Monoid(Monoid(mappend, mempty))+import Data.Ord(Ord)+import Prelude(Show)++data SimulatorTimeReport =+  SimulatorTimeReport {+    _hoursTotalSimulator ::+      TimeAmount+  , _hoursInstrumentSimulator ::+      TimeAmount+  }+  deriving (Eq, Ord, Show)++makeClassy ''SimulatorTimeReport++instance Monoid SimulatorTimeReport where+  mempty =+    SimulatorTimeReport+      mempty+      mempty+  SimulatorTimeReport t1 i1 `mappend` SimulatorTimeReport t2 i2 =+    SimulatorTimeReport (t1 `mappend` t2) (i1 `mappend` i2)++singleSimulatorTimeReport ::+  Entry a b c d+  -> SimulatorTimeReport+singleSimulatorTimeReport (SimulatorFlightEntry fl _) =+  SimulatorTimeReport+    (fl ^. simulatorTime)+    (fl ^. instrumentsimulatorTime)+singleSimulatorTimeReport _ =+  mempty++getSimulatorTimeReport ::+  Logbook a b c d+  -> SimulatorTimeReport+getSimulatorTimeReport (Logbook _ (Entries es)) =+  foldl' (\a -> mappend a . singleSimulatorTimeReport) mempty es
+ src/Data/Aviation/Casr/Logbook/Reports/TakeOffLanding90.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE TemplateHaskell #-}++module Data.Aviation.Casr.Logbook.Reports.TakeOffLanding90(+  TakeOffLanding90(..)+, HasTakeOffLanding90(..)+) where++import Control.Lens(makeClassy)+import Data.Aviation.Casr.Logbook(FlightPoint)+import Data.Eq(Eq)+import Data.Ord(Ord)+import Data.Time(Day)+import Prelude(Show)++data TakeOffLanding90 =+  TakeOffLanding90 {+    _takeoff1 ::+      FlightPoint+  , _takeoff2 ::+      FlightPoint+  , _takeoff3 ::+      FlightPoint+  , _landing1 ::+      FlightPoint+  , _landing2 ::+      FlightPoint+  , _landing3 ::+      FlightPoint+  , _currency90 ::+      Day+  }+  deriving (Eq, Ord, Show)++makeClassy ''TakeOffLanding90
+ test/doctests.hs view
@@ -0,0 +1,32 @@+module Main where++import Build_doctests (deps)+import Control.Applicative+import Control.Monad+import Data.List+import System.Directory+import System.FilePath+import Test.DocTest++main ::+  IO ()+main =+  getSources >>= \sources -> doctest $+      "-isrc"+    : "-idist/build/autogen"+    : "-optP-include"+    : "-optPdist/build/autogen/cabal_macros.h"+    : "-hide-all-packages"+    : map ("-package="++) deps ++ sources++getSources :: IO [FilePath]+getSources = filter (isSuffixOf ".hs") <$> go "src"+  where+    go dir = do+      (dirs, files) <- getFilesAndDirectories dir+      (files ++) . concat <$> mapM go dirs++getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])+getFilesAndDirectories dir = do+  c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir+  (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c