module Language.DTC.Utils where import Control.Applicative (Applicative(..)) import Data.Eq (Eq) import Data.Function (($), (.)) import Data.Functor (Functor(..), (<$>)) import Text.Show (Show) -- * Type 'PaddedList' data PaddedList a = PaddedList { padded :: [a] , padder :: a } deriving (Eq, Show) instance Functor PaddedList where fmap = (<*>) . pure instance Applicative PaddedList where pure = PaddedList [] PaddedList xs x <*> PaddedList ys y = zapp xs ys `PaddedList` x y where zapp [] bs = x <$> bs zapp as [] = ($ y) <$> as zapp (a : as) (b : bs) = a b : zapp as bs