module HNum.F where
import HNum.Vector
import HNum.CSV
class Functor f => FuncTools f where
hflat :: ([a] -> a) -> f a -> a
hlift :: ([a] -> [b]) -> f a -> f b
hmap :: (a -> b) -> f a -> f b
hfilter :: (a -> Bool) -> f a -> f a
htake :: Int -> f a -> f a
htakeWhile :: (a -> Bool) -> f a -> f a
hdrop :: Int -> f a -> f a
hdropWhile :: (a -> Bool) -> f a -> f a
instance FuncTools Vector where
hflat f = f . toList
hlift f = vec . f . toList
hmap = hlift . map
hfilter = hlift . filter
htake n = hlift (take n)
htakeWhile f = hlift (takeWhile f)
hdrop n = hlift (drop n)
hdropWhile f = hlift (dropWhile f)
instance FuncTools Matrix where
hflat = undefined
hlift f = matrix . map f . matForm
hmap = hlift . map
hfilter = hlift . filter
htake n = hlift (take n)
htakeWhile f = hlift (takeWhile f)
hdrop n = hlift (drop n)
hdropWhile f = hlift (dropWhile f)