Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (30 sloc) 1.03 KB
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
unit indef where
signature Abstract where
import GHC.TypeLits
data NatType :: Nat -- comment this out
-- type NatType = 32 -- and uncomment this to make it compile
module Util where
import Abstract
import Data.Proxy
import GHC.TypeLits
natTypeToInteger :: KnownNat NatType => Proxy NatType -> Integer
natTypeToInteger = natVal
unit concrete where
module Concrete where
type NatType = 32
unit main where
dependency indef[Abstract=concrete:Concrete] (Util as MyUtil)
module Main where
import Data.Proxy
import MyUtil
main :: IO ()
main = do putStr "Nat type is: "
print $ natTypeToInteger Proxy
putStrLn ""
You can’t perform that action at this time.