Skip to content

Instantly share code, notes, and snippets.

@mxswd
Created September 23, 2013 04:58
Show Gist options
  • Save mxswd/6666577 to your computer and use it in GitHub Desktop.
Save mxswd/6666577 to your computer and use it in GitHub Desktop.
{-#LANGUAGE GADTs, EmptyDataDecls, DataKinds, KindSignatures #-}
-- kind
data ListCont = Empty | NonEmpty
data SafeList a (b :: ListCont) where
Nil :: SafeList a Empty
Cons:: a -> SafeList a b -> SafeList a NonEmpty
safeHead :: SafeList a NonEmpty -> a
safeHead (Cons x _) = x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment