TypeApplications
TypeApplications 拡張を使えば Proxy :: Proxy "abc"
を Proxy @ "abc"
のように記述することができる。
ghci による確認
(hs)ghci> import Data.Proxy GHC.TypeLits
ghci> :set -XDataKinds -XTypeApplications
TypeApplications なし
(hs)ghci> :t Proxy :: Proxy "abc"
Proxy :: Proxy "abc" :: Proxy "abc"
TypeApplications あり
(hs)ghci> > :t Proxy @ "abc"
Proxy @ "abc" :: Proxy "abc"
ghci> p = Proxy @ "abc"
ghci> symbolVal p
"abc"
ghci> :t natVal
natVal :: KnownNat n => proxy n -> Integer
ghci> p2 = Proxy @ 100
ghci> natVal p2
100
関連する記録