News for hackers. Stuff that matters.
Re:Dependent Haskell by huntie on Tuesday December 18, 2018 @02:12AM (#18705024)
Dependent types are types which depend on values. As an example, think of the cons procedure: (List A, A) -> List A. It takes a List of A's and an A and returns a List of A's. With dependent types you can write this as (List n A, A) -> List n+1 A. This tells us that cons takes a List of A's with length n and an A returns a List of A's with length n+1.

Edwin Brady shows off some examples in Idris here[1]. I thought the matrix example was really impressive.

[1] https://www.youtube.com/watch?v=mOtKD7ml0NU

Re:Dependent Haskell by joe_the_user on Tuesday December 18, 2018 @03:18AM (#18705219)
When I see this definition, I scratch my head and wonder why this isn't a different way to introduce object orientation, generics, c++ parameterized templates and such.
Re:Dependent Haskell by logicchains on Tuesday December 18, 2018 @05:36AM (#18705645)
The key difference with C++ templates is that in C++ you can't have a type parameterised by a value that's only know at runtime, e.g. a std::array<N> where N is read from stdin. In a dependently typed language, you can. Object orientation is a different matter entirely; in the sense it implies Java-style class-based inheritance, it's almost in the opposite spirit to dependent types, as such late-binding (virtual methods) means it's possible to call methods such that the compiler has no idea which method will be called at compile time, making it hard to reason about the code at compile time.
Re:Dependent Haskell by RossBencina on Tuesday December 18, 2018 @04:19AM (#18705409)
Yes. C++ templates provide some subset of what you can do with dependent types in Idris.