diff options
Diffstat (limited to 'src/Data.hs')
-rw-r--r-- | src/Data.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Data.hs b/src/Data.hs index 8005737..00790fe 100644 --- a/src/Data.hs +++ b/src/Data.hs @@ -129,7 +129,7 @@ vecGenerate = \n f -> go n f SZ unsafeCoerceRefl :: a :~: b unsafeCoerceRefl = unsafeCoerce Refl -data Bag t = BNone | BOne t | BTwo (Bag t) (Bag t) | BMany [Bag t] +data Bag t = BNone | BOne t | BTwo !(Bag t) !(Bag t) | BMany [Bag t] | BList [t] deriving (Show, Functor, Foldable, Traversable) -- | This instance is mostly there just for 'pure' @@ -139,6 +139,7 @@ instance Applicative Bag where BOne f <*> b = f <$> b BTwo b1 b2 <*> b = BTwo (b1 <*> b) (b2 <*> b) BMany bs <*> b = BMany (map (<*> b) bs) + BList bs <*> b = BMany (map (<$> b) bs) instance Semigroup (Bag t) where (<>) = BTwo instance Monoid (Bag t) where mempty = BNone |