Skip to content

Instantly share code, notes, and snippets.

@Heimdell
Created January 3, 2016 20:05
Show Gist options
  • Save Heimdell/f3e1b86596c832bc3f37 to your computer and use it in GitHub Desktop.
Save Heimdell/f3e1b86596c832bc3f37 to your computer and use it in GitHub Desktop.
module InvertedReg where
import Control.Monad
import Control.Applicative
import Data.Monoid
data Generator s = Gen { generate :: [s] }
instance Monoid (Generator s) where
mempty = Gen []
mappend (Gen ls) (Gen rs) =
Gen (zipDiagonallyWith mappend ls rs)
zipDiagonallyWith f ls rs = map (uncurry mappend) (zipDiagonally ls rs)
zipDiagonally ls rs = go 1
where
go n = ls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment