Created
November 10, 2017 05:48
-
-
Save msmorgan/bd191cb971fa6a2ef38c66eaedcf6a67 to your computer and use it in GitHub Desktop.
This file contains 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 Data.AltList | |
%access public export | |
%default total | |
data AltList : (a : Type) -> (b : Type) -> Type where | |
Nil : AltList a b | |
ConsB : b -> AltList a b -> AltList a b | |
ConsAB : a -> b -> AltList a b -> AltList a b | |
data IsConsB : AltList a b -> Type where | |
ItIsConsB : IsConsB (ConsB x xs) | |
namespace ConsB | |
(::) : b -> AltList a b -> AltList a b | |
(::) = ConsB | |
namespace ConsA | |
(::) : a -> (xs : AltList a b) -> {auto ok : IsConsB xs} -> AltList a b | |
(::) x (ConsB y xs) = ConsAB x y xs | |
stringIntList : AltList String Int | |
stringIntList = ["hello", 1, "world", 2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This allows any number of
b
s in sequence, rather than requiring them to alternate.