I'd like to go from a type to value as follows, but without using the depreciated DatatypeContexts:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DatatypeContexts #-}
import Data.Proxy
import GHC.TypeLits
data (KnownNat n) => MagicN n a = MagicN a
deriving (Show)
getMagicN :: forall n. (KnownNat n) => MagicN n Integer
getMagicN = MagicN $ natVal (Proxy :: Proxy n)
MagicN five = getMagicN :: MagicN 5 Integer
I'm not too concerned if this or another method (Peano numbers etc) is used; the requirement is to be able to construct the value from the type information alone.
Thanks!