blob: fce4e96a8afc0e6666ee84a9f6c1d80f605e5742 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
{-# LANGUAGE MultiParamTypeClasses, KindSignatures, FlexibleInstances, DataKinds, PolyKinds, RankNTypes, AllowAmbiguousTypes, TypeOperators, TypeFamilies, ScopedTypeVariables #-}
{-# OPTIONS_GHC -fplugin DefaultLifted -fwarn-type-defaults #-}
-- Tests defaulting plugins
module Main where
import GHC.TypeLits
import Data.Proxy
import DefaultLifted
instance DefaultType Nat 4
instance DefaultType Nat 2
instance DefaultType Nat 0
class MyClass (a :: Nat) (b :: Nat) where
mc :: (KnownNat a, KnownNat b) => Proxy a -> Proxy b -> Integer
instance MyClass a b where
mc a b = natVal a + natVal b
q :: forall (a :: Nat). (KnownNat a) => Integer
q = natVal (Proxy :: Proxy a)
w :: forall (a :: Nat). (KnownNat a, 2 <= a) => Integer
w = natVal (Proxy :: Proxy a)
main :: IO ()
main = do
print $ q + w
print $ mc Proxy Proxy
|