hasklepias 0.4.3 → 0.4.4
raw patch · 6 files changed
+57/−23 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Hasklepias.Reexports: data Day
+ Hasklepias.Reexports: data Integer
+ Hasklepias.Reexports: diffDays :: Day -> Day -> Integer
+ Hasklepias.Reexports: fromGregorian :: Year -> MonthOfYear -> DayOfMonth -> Day
+ Hasklepias.Reexports: id :: a -> a
+ Hasklepias.Reexports: type MonthOfYear = Int
+ Hasklepias.Reexports: type Year = Integer
+ Hasklepias.Reexports: zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
+ Hasklepias.Types.Feature: FFF :: (Feature f -> Feature e -> Feature d) -> FeatureDefinition f e a d
+ Hasklepias.Types.Feature: applyFFF :: FeatureDefinition f e * d -> Feature f -> Feature e -> Feature d
+ Hasklepias.Types.Feature: defineFFF :: MissingReason -> MissingReason -> (f -> e -> d) -> FeatureDefinition f e * d
- Hasklepias.Types.Feature: EF :: (Events a -> Feature d) -> FeatureDefinition e a d
+ Hasklepias.Types.Feature: EF :: (Events a -> Feature d) -> FeatureDefinition f e a d
- Hasklepias.Types.Feature: FEF :: (Feature e -> Events a -> Feature d) -> FeatureDefinition e a d
+ Hasklepias.Types.Feature: FEF :: (Feature e -> Events a -> Feature d) -> FeatureDefinition f e a d
- Hasklepias.Types.Feature: applyEF :: FeatureDefinition e a d -> Events a -> Feature d
+ Hasklepias.Types.Feature: applyEF :: FeatureDefinition * * a d -> Events a -> Feature d
- Hasklepias.Types.Feature: applyFEF :: FeatureDefinition e a d -> Feature e -> Events a -> Feature d
+ Hasklepias.Types.Feature: applyFEF :: FeatureDefinition * e a d -> Feature e -> Events a -> Feature d
- Hasklepias.Types.Feature: data FeatureDefinition e a d
+ Hasklepias.Types.Feature: data FeatureDefinition f e a d
- Hasklepias.Types.Feature: defineEF :: Intervallic Interval a => MissingReason -> (Events a -> Maybe c) -> (c -> d) -> FeatureDefinition e a d
+ Hasklepias.Types.Feature: defineEF :: Intervallic Interval a => MissingReason -> (Events a -> Maybe c) -> (c -> d) -> FeatureDefinition * e a d
- Hasklepias.Types.Feature: defineFEF :: Intervallic Interval a => MissingReason -> (e -> Events a -> d) -> FeatureDefinition e a d
+ Hasklepias.Types.Feature: defineFEF :: Intervallic Interval a => MissingReason -> (e -> Events a -> d) -> FeatureDefinition * e a d
- Hasklepias.Types.Feature: defineFEF2 :: Intervallic Interval a => MissingReason -> (e -> Events a -> Feature d) -> FeatureDefinition e a d
+ Hasklepias.Types.Feature: defineFEF2 :: Intervallic Interval a => MissingReason -> (e -> Events a -> Feature d) -> FeatureDefinition * e a d
Files
- ChangeLog.md +5/−0
- examples/ExampleFeatures1.hs +9/−9
- examples/ExampleFeatures3.hs +1/−1
- hasklepias.cabal +1/−1
- src/Hasklepias/Reexports.hs +10/−4
- src/Hasklepias/Types/Feature.hs +31/−8
ChangeLog.md view
@@ -1,5 +1,10 @@ # Changelog for hasklepias +## 0.4.4++* Adds the `FFF` option to `FeatureDefinition` to define `(Feature f -> Feature e -> Feature d)` along with corresponding `defineFFF` and `applyFFF`.+* Adds `zipWith`, `id`, and `Integer` to re-exports.+ ## 0.4.3 * Exports `Feature` constructor.
examples/ExampleFeatures1.hs view
@@ -26,7 +26,7 @@ Index is defined as the first occurrence of an Orca bite. -} indexDef :: (Intervallic Interval a) =>- FeatureDefinition e a (Interval a)+ FeatureDefinition * e a (Interval a) indexDef = defineEF (Other "No occurrence of Orca bite") (firstConceptOccurrence ["wasBitByOrca"])@@ -57,7 +57,7 @@ Define enrolled as the indicator of whether all of the gaps between the union of all enrollment intervals (+ allowableGap) -}-enrolledDef :: IntervalSizeable a b => b -> FeatureDefinition (Interval a) a Bool+enrolledDef :: IntervalSizeable a b => b -> FeatureDefinition * (Interval a) a Bool enrolledDef allowableGap = defineFEF Excluded ( \i -> maybe False (all (< allowableGap) . durations)@@ -72,7 +72,7 @@ bit/struck by a macaw. -} makeHxDef :: (Intervallic Interval a) =>- [Text] -> FeatureDefinition (Interval a) a (Bool, Maybe (Interval a))+ [Text] -> FeatureDefinition * (Interval a) a (Bool, Maybe (Interval a)) makeHxDef cnpts = defineFEF Excluded ( \i es -> (isNotEmpty (f i es), lastMay $ intervals (f i es))@@ -80,17 +80,17 @@ where f i x = makePairedFilter enclose i (`hasConcepts` cnpts) x duckHxDef :: (Intervallic Interval a) =>- FeatureDefinition (Interval a) a (Bool, Maybe (Interval a))+ FeatureDefinition * (Interval a) a (Bool, Maybe (Interval a)) duckHxDef = makeHxDef ["wasBitByDuck", "wasStruckByDuck"] macawHxDef :: (Intervallic Interval a) =>- FeatureDefinition (Interval a) a (Bool, Maybe (Interval a))+ FeatureDefinition * (Interval a) a (Bool, Maybe (Interval a)) macawHxDef = makeHxDef ["wasBitByMacaw", "wasStruckByMacaw"] -- | Define an event that identifies whether the subject has two minor or one major -- surgery. twoMinorOrOneMajorDef :: (Intervallic Interval a) =>- FeatureDefinition (Interval a) a Bool+ FeatureDefinition * (Interval a) a Bool twoMinorOrOneMajorDef = defineFEF Excluded ( \i es -> twoXOrOneY ["hadMinorSurgery"] ["hadMajorSurgery"] (filterEnclose i es)@@ -100,7 +100,7 @@ -- with 5 day grace period timeSinceLastAntibioticsDef :: ( Intervallic Interval a , IntervalSizeable a b) =>- FeatureDefinition (Interval a) a (Maybe b)+ FeatureDefinition * (Interval a) a (Maybe b) timeSinceLastAntibioticsDef = defineFEF Excluded ( \i es -> ( lastMay -- want the last one@@ -116,7 +116,7 @@ -- | Count of hospital events in a interval and duration of the last one countOfHospitalEventsDef :: (IntervalCombinable Interval a , IntervalSizeable a b) =>- FeatureDefinition (Interval a) a (Int, Maybe b)+ FeatureDefinition * (Interval a) a (Int, Maybe b) countOfHospitalEventsDef = defineFEF Excluded ( \i es -> ((\x -> (length x, duration <$> lastMay x))@@ -136,7 +136,7 @@ discontinuationDef :: (IntervalSizeable a b , Intervallic Interval a) =>- FeatureDefinition (Interval a) a (Maybe (a, b))+ FeatureDefinition * (Interval a) a (Maybe (a, b)) discontinuationDef = defineFEF Excluded ( \i es -> (\x -> Just (begin x -- we want the begin of this interval
examples/ExampleFeatures3.hs view
@@ -24,7 +24,7 @@ examplePairComparison :: (Intervallic Interval a , IntervalSizeable a b) =>- FeatureDefinition (Interval a) a (Bool, Maybe a)+ FeatureDefinition * (Interval a) a (Bool, Maybe a) examplePairComparison = defineFEF Unknown ( \i es -> es
hasklepias.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: hasklepias-version: 0.4.3+version: 0.4.4 description: Please see the README on GitHub at <https://github.com/novisci/asclepias#readme> homepage: https://github.com/novisci/asclepias/#readme bug-reports: https://github.com/novisci/asclepias/issues
src/Hasklepias/Reexports.hs view
@@ -12,9 +12,11 @@ module Hasklepias.Reexports ( -- * Re-exports- module Control.Monad+ module GHC.Num+ , module Control.Monad , module Control.Applicative , module Data.Bool+ , module Data.Time.Calendar , module Data.Int , module Data.Maybe , module Data.Function@@ -27,16 +29,18 @@ , module Flow ) where +import safe GHC.Num ( Integer ) import safe Control.Monad ( (=<<) ) import safe Control.Applicative ( (<$>) ) import safe Data.Bool ( Bool(..) , (&&), not, (||) , bool , otherwise )-import safe Data.Function ( (.), ($), const )+import safe Data.Function ( (.), ($), const, id ) import safe Data.Functor ( fmap ) import safe Data.Int ( Int )-import safe Data.List ( all, map, filter, length, null )+import safe Data.List ( all, map, filter, length, null+ , zipWith ) import safe Data.Maybe ( Maybe(..), maybe, isJust,@@ -49,7 +53,9 @@ maybeToList ) import safe Data.Ord ( Ord((>=), (<), (>), (<=)) , max, min )-import safe Data.Time.Calendar ( Day, fromGregorian, MonthOfYear, Year )+import safe Data.Time.Calendar ( Day, MonthOfYear, Year+ , fromGregorian+ , diffDays ) import safe Data.Text ( pack, Text ) import safe Data.Tuple ( fst, snd, uncurry, curry ) import safe Flow ( (!>), (.>), (<!), (<.), (<|), (|>) )
src/Hasklepias/Types/Feature.hs view
@@ -18,11 +18,13 @@ Feature(..) , MissingReason(..) , FeatureDefinition(..)- , applyEF , defineEF , defineFEF , defineFEF2+ , defineFFF+ , applyEF , applyFEF+ , applyFFF , featureR , featureL @@ -30,7 +32,7 @@ import GHC.Read ( Read ) import GHC.Show ( Show )-import GHC.Generics ( Generic, D )+import GHC.Generics ( Generic ) import Data.Either ( Either(..) ) import Data.Eq ( Eq ) import Data.Functor ( Functor(fmap) )@@ -67,9 +69,10 @@ -- | A type to hold common feature definitions; i.e. functions that return -- features.-data FeatureDefinition e a d =+data FeatureDefinition f e a d = EF (Events a -> Feature d) | FEF (Feature e -> Events a -> Feature d)+ | FFF (Feature f -> Feature e -> Feature d) -- | Define an 'EF' FeatureDefinition defineEF :: (Intervallic Interval a) =>@@ -84,7 +87,7 @@ -> (c -> d) -- ^ A function that transforms the intermediary data to the desired -- type.- -> FeatureDefinition e a d+ -> FeatureDefinition * e a d defineEF r f g = EF (\es -> case f es of Nothing -> featureL r@@ -92,29 +95,31 @@ ) -- | Extract an 'EF' FeatureDefinition.-applyEF :: FeatureDefinition e a d -> Events a -> Feature d+applyEF :: FeatureDefinition * * a d -> Events a -> Feature d applyEF (EF f) = f +-- | TODO defineFEF :: (Intervallic Interval a) => MissingReason -- ^ The reason if the input 'Feature' is a 'Left'. -> (e -> Events a -> d) -- ^ A function that tranforms the data of a 'Right' input 'Feature' -- and a collection of events into the desired type.- -> FeatureDefinition e a d+ -> FeatureDefinition * e a d defineFEF r g = FEF (\(Feature feat) es -> case feat of (Left _) -> featureL r (Right x) -> featureR (g x es) ) +-- | TODO defineFEF2 :: (Intervallic Interval a) => MissingReason -- ^ The reason if the input 'Feature' is a 'Left'. -> (e -> Events a -> Feature d) -- ^ A function that tranforms the data of a 'Right' input 'Feature' -- and a collection of events into the desired type.- -> FeatureDefinition e a d+ -> FeatureDefinition * e a d defineFEF2 r g = FEF (\(Feature feat) es -> case feat of (Left _) -> featureL r@@ -122,5 +127,23 @@ ) -- | Extract a 'FEF' FeatureDefinition-applyFEF :: FeatureDefinition e a d -> Feature e -> Events a -> Feature d+applyFEF :: FeatureDefinition * e a d -> Feature e -> Events a -> Feature d applyFEF (FEF f) = f++-- | TODO+defineFFF :: + MissingReason+ -> MissingReason + -> (f -> e -> d) + -> FeatureDefinition f e * d+defineFFF r1 r2 g = FFF (\(Feature feat1) (Feature feat2) ->+ case ( feat1, feat2 ) of + ( Left _ , Left _ ) -> featureL r1+ ( Left _ , _ ) -> featureL r1+ ( _ , Left _ ) -> featureL r2+ ( Right x, Right y) -> featureR $ g x y+ )++-- | Extract a 'FFF' FeatureDefinition+applyFFF :: FeatureDefinition f e * d -> Feature f -> Feature e -> Feature d+applyFFF (FFF f) = f