equality,proof,agda,dependent-type,heterogeneous

In fact it should be easy to show that get (ρ′ , x′) equals get (ε ∷ ρ′ , suc⁺ x′). First, the reason that Agda does not see this equality is that the functions suc⁺ doesn't reduce for an argument of a general form x'. This is because...

pattern-matching,proof,agda,dependent-type

You can use the Agda keyword rewrite to apply a propositional equivalence on your goal: insertCorrect : ∀ {n} -> ∀ x l -> sorted n l -> sorted (n ⊓ x) (insert x l) insertCorrect {n} x nil p with intDec n x insertCorrect {n} x nil p |...

haskell,theorem-proving,dependent-type,higher-rank-types

I'm reading it as "given a term which requires l ~ r, return that term" It's "given a term whose type contains l, return that term with all ls being substituted by rs in the type" (or in the other direction r -> l). It's a very neat trick,...

c++,templates,language-lawyer,dependent-type,compiler-bug

Let's go back to when typename is required. §14.6 [temp.res]/p3, all quotes are from N4140: When a qualified-id is intended to refer to a type that is not a member of the current instantiation (14.6.2.1) and its nested-name-specifier refers to a dependent type, it shall be prefixed by the keyword...

I think generic parameters might be an easier way to describe this pattern. You can avoid the generic parameter all together, however, by explicitly identifying the type T on both the Container instances: case class Identity(c: Container) extends Transform { val from: Container { type T = c.T } =...

The problem with using -> in this way is that it's not a type constructor but a binder, where the name bound for the domain is in scope in the range, so -> itself doesn't have a type directly. Your definition of t for example wouldn't capture a dependent type...

The key idea is that the first element of the vector is f 0, and for the tail, if you have k : Fin n, then FS k : Fin (S n) is a "shift" of the finite number that increments its value and its type at the same time....

logic,prefix,dependent-type,idris

I think the only problem here is that you've used [a] as the type of lists of a, in the Haskell style, whereas in Idris it needs to be List a. Your Prefix type looks fine to me, although I'd write it as: data Prefix : List a -> List...

What you describe is not currying. It's a simple swapping of arguments. Here's how currying looks like: open import Data.Product hiding (curry) -- non-dependent version curry′ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (A × B → C) →...

You just need to rewrite in the another direction: open import Relation.Binary.PropositionalEquality insert : ∀ {A n} -> A -> T A n -> T A (suc n) insert x empty = leaf x insert x (leaf y) = bal (leaf y) (leaf y) insert x (bal l r) =...

haskell,polymorphism,dependent-type,data-kinds,type-kinds

There is no1 such thing as "types with kinds other than *". Kind * is the kind for types, much like Int is the type for machine-sized numbers; other kinds may contain stuff that resembles types or can be converted to types or is used to index types or whatever...

c++,templates,language-lawyer,dependent-type,compiler-bug

I'm using a post-N4296 draft. typedef I<sizeof(sizeof(T))>::Type Type; typename is required if the nested-name-specifier I<..> depends on a template parameter [temp.res]/5. So, is I<..> dependent? [temp.dep.type]/9 A type is dependent if it is [...] (9.7) a simple-template-id in which either the template name is a template parameter or any of...

Matching on a Type is known as type-casing. Being able to do this would break a concept called parametricity which is very valuable. http://stackoverflow.com/a/23224110/108359 Idris does not support type-casing. I think it may have tried at one stage, but people gave up on that quickly. It also used to give...

In practice, you may do better to simply check the bounds as needed, but you can certainly write a data type to enforce such a property. One straightforward way to do it is like this: data Range : Ord a => a -> a -> Type where MkRange : Ord...

scala,implicit-conversion,dependent-type,path-dependent-type

You need to be sure not to throw away the Return values in your instance methods' return types: trait ToTreeMap[M[_, _], K, V] { type Result def treeMap(x: M[K, V]): TreeMap[K, Result] } trait LowerPriorityToTreeMap { implicit def plainMap[K, V]( implicit ord: Ordering[K] ): ToTreeMap[Map, K, V] { type Result...

coq,dependent-type,convoy-pattern

You got it almost right. The issue is in your return clause, which is non-dependent. What you need is match n return forall (w: svector A n), (svector_is_dense w) -> (Vector.t A n) with so that D0 is not of type svector_is_dense v as it would be in your case,...

scala,types,dependent-type,path-dependent-type

Because the return type of int2pair is just Pair, not Pair { type N = _2 }. The if/else happens at runtime, the compiler can't know which branch will be taken. AFAIK the only way to go from value to type is with a macro. You might want to look...

You want to do destruct (split A B tx). This will break it up, binding the two pieces to ta and tb

haskell,types,binding,dependent-type

The type you suggest can not be implemented, i.e. it is not inhabited: takeWhileVector :: (a -> Bool) -> Vector a n -> Vector a m Remember that the caller chooses the type variables a,n,m. This means that the caller can use your function as e.g. takeWhileVector :: (a ->...

{-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ExplicitForAll #-} import Data.Type.Equality data Nat = Z | S Nat type family (n :: Nat) :+ (m :: Nat) :: Nat where Z :+ m = m...

Here's something potentially interesting... {-# LANGUAGE DataKinds, KindSignatures, ScopedTypeVariables #-} import GHC.TypeLits import Data.Proxy data Bar (n :: Nat) = Bar String deriving Show bar :: KnownNat n => Bar n -> (String, Integer) bar [email protected](Bar s) = (s, natVal b) Ok, it's very pointless. But it's an example of...

This is a logged as issue 5712 which for some reason is called an "improvement" not bug. So currently constructors cannot resolve dependent types with multiple argument lists, it seems.

pred is a function taking a sig type (try to Print sig.). Simply put, it's an inductive type with one constructor stating that "there exists an x of type A such that P x is true". If you want to create a term of type {n : nat | n...

haskell,lambda-calculus,dependent-type

We need some kind of context to keep track of the lambda arguments. However, we don't necessarily need to instantiate them, since bound gives us de Bruijn indices, and we can use those indices to index into the context. Actually using the indices is a bit involved, though, because of...

types,functional-programming,agda,dependent-type

That's why Agda has dot patterns: accCorrect : (r : RE) (s : List Char) (s1 : List Char) (s2 : List Char) (k : (List Char -> Bool)) -> ( (s1 ++ s2) ≡ s) -> (REMatch s1 r) -> (k s2 ≡ true) -> (acc r s k...

scala,case-class,dependent-type,dotty

The multiple parameter list approach for dependent types unfortunately is not supported for constructors, so no, you will have to introduce a type parameter. You could hide that fact if it becomes bothering, though trait Stateful { type State } object SystemState { def apply(system: Stateful)(state: system.State): SystemState = new...

It's really odd that people think pattern matching on types is bad. We get a lot of mileage out of pattern matching on data which encode types, whenever we do a universe construction. If you take the approach that Thorsten Altenkirch and I pioneered (and which my comrades and I...

types,dynamic-typing,static-typing,dependent-type

Dependent types (pis) are basically "beefed up" forms of function spaces (arrows). If you see: Pi x : T. T(x) Then it's a type that's basically saying "give me an x of type T, I'll give you something of type T(x)" In the degenerate case where T does not have...

haskell,isabelle,dependent-type

"Haskabelle is a converter from Haskell source files to Isabelle/HOL theories implemented in Haskell itself." Haskabelle...

haskell,dependent-type,data-kinds,type-kinds

In current GHC (7.8 at time of writing), one cannot separate the declaration of a fresh kind from the declaration of its type-level inhabitants.