system-f

Type abstraction in GHC Haskell

荒凉一梦 提交于 2019-12-30 09:05:05
问题 I'd love to get the following example to type-check: {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} module Foo where f :: Int -> (forall f. Functor f => Secret f) -> Int f x _ = x g :: (forall f. Functor f => Secret f) -> Int g = f 4 type family Secret (f :: * -> *) :: * where Secret f = Int I get it that it's probably not possible to infer and check g s type (even though in this specific case it's obvious

Modeling System F's parametric polymorphism at Set₀

三世轮回 提交于 2019-12-11 12:13:29
问题 In System F, the kind of a polymorphic type is * (as that's the only kind in System F anyway...), so e.g. for the following closed type: [] ⊢ (forall α : *. α → α) : * I would like to represent System F in Agda, and because everything is in * , I thought I'd interpret types (like the above) as Agda Set s; so something like evalTy : RepresentationOfAWellKindedClosedType → Set However, Agda doesn't have polymorphic types, so the above type, in Agda, would need to be a (large!) Π type: idType =

Type abstraction in GHC Haskell

六月ゝ 毕业季﹏ 提交于 2019-12-01 04:31:12
I'd love to get the following example to type-check: {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} module Foo where f :: Int -> (forall f. Functor f => Secret f) -> Int f x _ = x g :: (forall f. Functor f => Secret f) -> Int g = f 4 type family Secret (f :: * -> *) :: * where Secret f = Int I get it that it's probably not possible to infer and check g s type (even though in this specific case it's obvious because it's just a partial application): Secret is not injective and there's no way to tell the compiler