Created
January 3, 2016 20:05
-
-
Save Heimdell/f3e1b86596c832bc3f37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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