Skip to content

Instantly share code, notes, and snippets.

@chris-martin
Created January 18, 2017 06:20
Show Gist options
  • Save chris-martin/67274e6a8a79a89dd932582c8b3669c3 to your computer and use it in GitHub Desktop.
Save chris-martin/67274e6a8a79a89dd932582c8b3669c3 to your computer and use it in GitHub Desktop.
newtype ConjList a = ConjList [a] deriving Show
instance Monoid a => Monoid (ConjList a) where
mempty = ConjList $ repeat mempty
mappend (ConjList x) (ConjList y) = ConjList $ zipWith mappend x y
λ> mappend (ConjList ["ab", "cd"]) (ConjList ["xc", "xy", "xp"])
ConjList ["abxc","cdxy"]
it :: (Monoid a, Data.String.IsString a) => ConjList a
λ> mappend (ConjList ["ab", "cd"]) mempty
ConjList ["ab","cd"]
it :: (Monoid a, Data.String.IsString a) => ConjList a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment