Created
November 14, 2015 23:52
-
-
Save twopoint718/23945badbd04032660a3 to your computer and use it in GitHub Desktop.
Not quite sure how to implement
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
{-# 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