Skip to content

Instantly share code, notes, and snippets.

Created March 9, 2013 02:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/5122217 to your computer and use it in GitHub Desktop.
Save anonymous/5122217 to your computer and use it in GitHub Desktop.
data StartsWithA a b = StartsWithA a (StartsWithB a b)
| EmptyA
deriving Show
data StartsWithB a b = StartsWithB b (StartsWithA a b)
| EmptyB
deriving Show
infixr 7 <<<
infixr 7 >>>
x >>> y = StartsWithA x y
x <<< y = StartsWithB x y
zipAB :: [a] -> [b] -> StartsWithA a b
zipAB (a : as) (b: bs) = a >>> (b <<< (zipAB as bs))
zipAB (a : as) _ = a >>> EmptyB
zipAB _ _ = EmptyA
main = putStrLn $ show $ (zipAB ["a", "b", "c"] [1, 2, 3], zipAB ["a", "b", "c"] [1, 2], zipAB ["a", "b"] [1, 2, 3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment