Skip to content

Instantly share code, notes, and snippets.

@twopoint718
Created November 14, 2015 23:52
Show Gist options
  • Save twopoint718/23945badbd04032660a3 to your computer and use it in GitHub Desktop.
Save twopoint718/23945badbd04032660a3 to your computer and use it in GitHub Desktop.
Not quite sure how to implement
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PolyKinds #-}
module Lits where
import GHC.TypeLits
import Data.Proxy
import Prelude hiding (showList)
-- I have no idea how to write this...
-- fromList :: forall n a . SomeNat n => [a] -> List n a
-- fromList [] = Nil
-- fromList (x:xs) = Cons x (fromList xs)
toList :: List n a -> [a]
toList Nil = []
toList (Cons x xs) = x : toList xs
data List :: Nat -> * -> * where
Cons :: a -> List (n-1) a -> List n a
Nil :: List 0 a
instance Show a => Show (List n a) where
show = show . toList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment