Commits

Aleksey Khudyakov committed 912c525

Add fromMaybeBin

  • Participants
  • Parent commits 284cd01

Comments (0)

Files changed (1)

Data/Histogram/Bin/MaybeBin.hs

 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 module Data.Histogram.Bin.MaybeBin (
     MaybeBin(..)
+  , fromMaybeBin
   ) where
 
 import Control.Monad   (liftM)
 
 import Data.Histogram.Bin.Classes
 import Data.Histogram.Bin.Read
+import qualified Data.Vector.Generic    as G
+import qualified Data.Histogram.Generic as H
+
 
 
 -- | This binning algorithms adds special case of no value.
   readPrec = do
     keyword "MaybeBin"
     liftM MaybeBin readPrec
+
+
+-- | Drop bin with no events
+fromMaybeBin :: (Bin b, G.Vector v a) => H.Histogram v (MaybeBin b) a -> H.Histogram v b a
+fromMaybeBin h = H.histogram b (G.tail $ H.histData h)
+  where
+    MaybeBin b = H.bins h