Skip to content

Instantly share code, notes, and snippets.

@miguel-vila
Created September 25, 2014 05:14
Show Gist options
  • Save miguel-vila/ff0e6c25c10362af7744 to your computer and use it in GitHub Desktop.
Save miguel-vila/ff0e6c25c10362af7744 to your computer and use it in GitHub Desktop.
def fa[A0,A1](a: A0): A1 = ???
def head[A](l: List[A]): A = l.head
def fmap[A,B](f: A => B)(l: List[A]): List[B] = l.map(f)
"head and then map is the same as map and then head" {
fa[A0,A1] compose head[A0] == head[A1] compose fmap[A0,A1](fa)
}
def tail[A](l: List[A]): List[A] = l.tail
"tail and then map is the same as map and then tail" {
fa[A0,A1] compose tail[A0] == tail[A1] compose fmap[A0,A1](fa)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment