Skip to content

Instantly share code, notes, and snippets.

@danking
Created April 26, 2015 19:46
Show Gist options
  • Save danking/22270f0d20418a6ec660 to your computer and use it in GitHub Desktop.
Save danking/22270f0d20418a6ec660 to your computer and use it in GitHub Desktop.
>_>
instance Monoid a => Monoid [(Either a b)] where
mempty = []
mappend [] vs = vs
mappend vs [] = vs
mappend [(Left v1)] ((Left v2):vs) = (Left $ mappend v1 v2):vs
mappend (v1:v2:vs) vs' = v1 : (mappend (v2:vs) vs')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment