Re: [Haskell-cafe] Type-Level Programming

2010-07-01 Thread wren ng thornton
Andrew Coppin wrote: wren ng thornton wrote: Andrew Coppin wrote: It's a bit like trying to learn Prolog from somebody who thinks that the difference between first-order and second-order logic is somehow common knowledge. (FWIW, I have absolutely no clue what that difference is.

Re: [Haskell-cafe] Type-Level Programming

2010-07-01 Thread wren ng thornton
Andrew Coppin wrote: I did wonder what the heck a type function is or why you'd want one. And then a while later I wrote some code along the lines of class Collection c where type Element c :: * empty :: c - Bool first :: c - Element c So now it's like Element is a function that

Re: [Haskell-cafe] Type-Level Programming

2010-06-28 Thread Brent Yorgey
On Fri, Jun 25, 2010 at 02:26:54PM -0700, Walt Rorie-Baety wrote: I've noticed over the - okay, over the months - that some folks enjoy the puzzle-like qualities of programming in the type system (poor Oleg, he's become #haskell's answer to the Chuck Norris meme commonly encountered in

Re: [Haskell-cafe] Type-Level Programming

2010-06-28 Thread Andrew Coppin
So is there a specific reason why Haskell isn't dependently typed then? Or you could ask, So is there a specific reason why C isn't a functional language? More to the point, Haskell was a bit too frozen in stone when dependent type theory reached the point of being implementable.

Re: [Haskell-cafe] Type-Level Programming

2010-06-28 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/28/10 15:04 , Andrew Coppin wrote: More to the point, Haskell was a bit too frozen in stone when dependent type theory reached the point of being implementable. Right. So, in summary, the answer is historical circumstance? (I was

Re: [Haskell-cafe] Type-Level Programming

2010-06-28 Thread Andrew Coppin
wren ng thornton wrote: Andrew Coppin wrote: I think I looked at Coq (or was it Epigram?) and found it utterly incomprehensible. Whoever wrote the document I was reading was obviously very comfortable with advanced mathematical abstractions which I've never even heard of. One of the things

Re: [Haskell-cafe] Type-Level Programming

2010-06-28 Thread Andrew Coppin
Brent Yorgey wrote: As several people have pointed out, type-level programming in Haskell resembles logic programming a la Prolog -- however, this actually only applies to type-level programming using multi-parameter type classes with functional dependencies [1] (which was until recently the

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Andrew Coppin
wren ng thornton wrote: And, as Jason said, if you're just interested in having the same programming style at both term and type levels, then you should look into dependently typed languages. Out of curiosity, what the hell does dependently typed mean anyway?

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Stephen Tetley
On 26 June 2010 08:07, Andrew Coppin andrewcop...@btinternet.com wrote: Out of curiosity, what the hell does dependently typed mean anyway? How about: The result type of a function may depend on the argument value (rather than just the argument type) The quoted bit rather than the parens bit

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Liam O'Connor
It means that not only can values have types, types can have values. An example of the uses of a dependent type would be to encode the length of a list in it's type. Due to the curry-howard isomorphism, dependent types open the gateway for lots of type-level theorem proving. On 26 June 2010

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Jason Dagit
On Sat, Jun 26, 2010 at 12:07 AM, Andrew Coppin andrewcop...@btinternet.com wrote: wren ng thornton wrote: And, as Jason said, if you're just interested in having the same programming style at both term and type levels, then you should look into dependently typed languages. Out of

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Jason Dagit
On Sat, Jun 26, 2010 at 12:27 AM, Jason Dagit da...@codersbase.com wrote: On Sat, Jun 26, 2010 at 12:07 AM, Andrew Coppin andrewcop...@btinternet.com wrote: wren ng thornton wrote: And, as Jason said, if you're just interested in having the same programming style at both term and type

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Andrew Coppin
Liam O'Connor wrote: It means that not only can values have types, types can have values. Uh, don't types have values *now*? An example of the uses of a dependent type would be to encode the length of a list in it's type. Oh, right. So you mean that as well as being able to say Foo

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Tony Morris
http://www.cs.nott.ac.uk/~txa/publ/ydtm.pdf Andrew Coppin wrote: Liam O'Connor wrote: It means that not only can values have types, types can have values. Uh, don't types have values *now*? An example of the uses of a dependent type would be to encode the length of a list in it's type.

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Andrew Coppin
Jason Dagit wrote: On Sat, Jun 26, 2010 at 12:07 AM, Andrew Coppin andrewcop...@btinternet.com mailto:andrewcop...@btinternet.com wrote: Out of curiosity, what the hell does dependently typed mean anyway? The types can depend on values. For example, have you ever notice we have

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Andrew Coppin
Tony Morris wrote: http://www.cs.nott.ac.uk/~txa/publ/ydtm.pdf Ah yes, it was definitely Epigram I looked at. The intro to this looked promising, but by about 3 pages in, I had absolutely no clue what on Earth the text is talking about... ___

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Gábor Lehel
On Sat, Jun 26, 2010 at 3:49 AM, wren ng thornton w...@freegeek.org wrote: Jason Dagit wrote: On Fri, Jun 25, 2010 at 2:26 PM, Walt Rorie-Baety black.m...@gmail.comwrote: I've noticed over the - okay, over the months - that some folks enjoy the puzzle-like qualities of programming in the

Re[2]: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Bulat Ziganshin
Hello Gábor, Saturday, June 26, 2010, 4:29:28 PM, you wrote: It's interesting how C++ is imperative at the term level and functional at the type level or logic? it supports indeterminate choice -- Best regards, Bulatmailto:bulat.zigans...@gmail.com

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Liam O'Connor
I prefer Agda to Epigram, but different strokes for different folks. In agda, you could define a list indexed by its size like this: data Vec : (A : Set) → ℕ → Set where [] : Vec A 0 _∷_ : ∀ {n : ℕ} → A → Vec A n → Vec A (1 + n) So, we have a Vec data type, and on the type level it is a

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Liam O'Connor
We most certainly do have type-level functions. See type families. Cheers. ~Liam On 26 June 2010 17:33, Jason Dagit da...@codersbase.com wrote: On Sat, Jun 26, 2010 at 12:27 AM, Jason Dagit da...@codersbase.com wrote: On Sat, Jun 26, 2010 at 12:07 AM, Andrew Coppin

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/26/10 07:28 , Andrew Coppin wrote: Uh, don't types have values *now*? To the extent that's true now, they're baked in; you can't do anything to/with them. Oh, right. So you mean that as well as being able to say Foo Bar, you can say Foo 7,

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread C. McCann
On Sat, Jun 26, 2010 at 3:27 AM, Jason Dagit da...@codersbase.com wrote: The types can depend on values.  For example, have you ever notice we have families of functions in Haskell like zip, zip3, zip4, ..., and liftM, liftM2, ...? Each of them has a type that fits into a pattern, mainly the

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Alexander Solla
On Jun 26, 2010, at 4:33 AM, Andrew Coppin wrote: It's a bit like trying to learn Prolog from somebody who thinks that the difference between first-order and second-order logic is somehow common knowledge. A first order logic quantifies over values, and a second order logic quantifies

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Andrew Coppin
Alexander Solla wrote: On Jun 26, 2010, at 4:33 AM, Andrew Coppin wrote: It's a bit like trying to learn Prolog from somebody who thinks that the difference between first-order and second-order logic is somehow common knowledge. A first order logic quantifies over values, and a second

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Andrew Coppin
Brandon S Allbery KF8NH wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/26/10 07:28 , Andrew Coppin wrote: Oh, right. So you mean that as well as being able to say Foo Bar, you can say Foo 7, where 7 is (of course) a value rather than a type. (?) A bit more than that:

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Jason Dagit
On Sat, Jun 26, 2010 at 11:23 AM, Andrew Coppin andrewcop...@btinternet.com wrote: Brandon S Allbery KF8NH wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/26/10 07:28 , Andrew Coppin wrote: Oh, right. So you mean that as well as being able to say Foo Bar, you can say Foo 7,

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Alexander Solla
On Jun 26, 2010, at 11:21 AM, Andrew Coppin wrote: A first order logic quantifies over values, and a second order logic quantifies over values and sets of values (i.e., types, predicates, etc). The latter lets you express things like For every property P, P x. Notice that this

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/26/10 14:58 , Jason Dagit wrote: On Sat, Jun 26, 2010 at 11:23 AM, Andrew Coppin andrewcop...@btinternet.com mailto:andrewcop...@btinternet.com wrote: Brandon S Allbery KF8NH wrote: A bit more than that: imagine now that you can

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Erik de Castro Lopo
Andrew Coppin wrote: Right, I see. So is there a specific reason why Haskell isn't dependently typed then? One problem with dependent types as I understand it is that type inference is not guaranteed to terminate. Erik --

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread C. McCann
On Sat, Jun 26, 2010 at 6:55 PM, Erik de Castro Lopo mle...@mega-nerd.com wrote: One problem with dependent types as I understand it is that type inference is not guaranteed to terminate. Full type inference is undecidable in most interesting type systems anyway. It's possible for the

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread wren ng thornton
Gregory Crosswhite wrote: On 6/25/10 9:49 PM, wren ng thornton wrote: [1] http://eclipse-clp.org/ is currently down, but can be accessed at http://87.230.22.228/ [2] http://www.mercury.csse.unimelb.edu.au/ [3] http://www.lix.polytechnique.fr/~dale/lProlog/ [4]

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread wren ng thornton
Andrew Coppin wrote: Stephen Tetley wrote: On 26 June 2010 08:07, Andrew Coppin andrewcop...@btinternet.com wrote: Out of curiosity, what the hell does dependently typed mean anyway? How about: The result type of a function may depend on the argument value (rather than just the argument

Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread wren ng thornton
Andrew Coppin wrote: I think I looked at Coq (or was it Epigram?) and found it utterly incomprehensible. Whoever wrote the document I was reading was obviously very comfortable with advanced mathematical abstractions which I've never even heard of. One of the things I've found when dealing

[Haskell-cafe] Type-Level Programming

2010-06-25 Thread Walt Rorie-Baety
I've noticed over the - okay, over the months - that some folks enjoy the puzzle-like qualities of programming in the type system (poor Oleg, he's become #haskell's answer to the Chuck Norris meme commonly encountered in MMORPGs). Anyway,... are there any languages out there whose term-level

Re: [Haskell-cafe] Type-Level Programming

2010-06-25 Thread Jason Dagit
On Fri, Jun 25, 2010 at 2:26 PM, Walt Rorie-Baety black.m...@gmail.comwrote: I've noticed over the - okay, over the months - that some folks enjoy the puzzle-like qualities of programming in the type system (poor Oleg, he's become #haskell's answer to the Chuck Norris meme commonly encountered

Re: [Haskell-cafe] Type-Level Programming

2010-06-25 Thread wren ng thornton
Jason Dagit wrote: On Fri, Jun 25, 2010 at 2:26 PM, Walt Rorie-Baety black.m...@gmail.comwrote: I've noticed over the - okay, over the months - that some folks enjoy the puzzle-like qualities of programming in the type system (poor Oleg, he's become #haskell's answer to the Chuck Norris meme

Re: [Haskell-cafe] Type-Level Programming

2010-06-25 Thread Gregory Crosswhite
Are any of those compatible with Haskell, so that we could mix code in that language with Haskell code? Cheers, Greg On 6/25/10 9:49 PM, wren ng thornton wrote: Jason Dagit wrote: On Fri, Jun 25, 2010 at 2:26 PM, Walt Rorie-Baety black.m...@gmail.comwrote: I've noticed over the - okay,

Re: [Haskell-cafe] type-level programming support library

2009-03-31 Thread spoon
On Mon, 2009-03-30 at 20:54 +0100, Lennart Augustsson wrote: I wasn't questioning the utility of John's library. But I saw him mentioning unary numbers and I think it's a mistake to use those for anything practical involving even moderately sized numbers. Also agreed! tfp supports rational

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread Lennart Augustsson
There is already a library for type level number, called typelevel. It's nice because it uses decimal representation of numbers and can handle numbers of reasonable size. I use it in the LLVM bindings. -- Lennart On Mon, Mar 30, 2009 at 1:07 AM, spoon sp...@killersmurf.com wrote: I've been

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread José Pedro Magalhães
Hello, I suppose Lennart is referring to type-level [1]. But type-level uses functional dependencies, right? There is also tfp [2], which uses type families. In general, how would you say your work compares to these two? Thanks, Pedro [1]

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread Edward Kmett
Lennart, I think the major emphasis that John's library has is on doing things other than numbers well in the type system, using the type family syntax to avoid the proliferation of intermediary names that the fundep approach yields. I think his type family approach for type-level monads for

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread John Van Enk
Haskell not having 'polymorphic kinds'. Is there a good description of why Haskell doesn't have polymorphic kinds? 2009/3/30 Edward Kmett ekm...@gmail.com Lennart, I think the major emphasis that John's library has is on doing things other than numbers well in the type system, using the

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread Martijn van Steenbergen
John Van Enk wrote: Haskell not having 'polymorphic kinds'. Is there a good description of why Haskell doesn't have polymorphic kinds? IANA expert but polymorphic kinds belong to a set of reasonably new influences (e.g. from dependently typed programming languages and generic

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread John Van Enk
I suppose having a good description of what I'd like to do might help: I'd like to be able to make an N-Tuple an instance of a type class. class Foo a where instance Foo (,) where instance Foo (,,) where The different kindedness of (,) and (,,) prevent this from

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread Edward Kmett
Thats a bit farther down the rabbit hole than the concern in question, though certainly related. An example of what you could write with polymorphic kinds, inventing a notation for polymorphic kind variables using 'x to denote a polymorphic kind x, which could subtitute in for a kind k = * | **

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread Lennart Augustsson
I wasn't questioning the utility of John's library. But I saw him mentioning unary numbers and I think it's a mistake to use those for anything practical involving even moderately sized numbers. I'd love to see a good type level programming library. There's a lot of it out there, but it's never

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread Edward Kmett
On Mon, Mar 30, 2009 at 3:54 PM, Lennart Augustsson lenn...@augustsson.netwrote: I wasn't questioning the utility of John's library. But I saw him mentioning unary numbers and I think it's a mistake to use those for anything practical involving even moderately sized numbers. Completely

Re: [Haskell-cafe] type-level programming support library

2009-03-30 Thread Claus Reinke
I suppose having a good description of what I'd like to do might help: I'd like to be able to make an N-Tuple an instance of a type class. class Foo a where instance Foo (,) where instance Foo (,,) where The different kindedness of (,) and (,,) prevent this from working. Not that this

[Haskell-cafe] type-level programming support library

2009-03-29 Thread spoon
I've been doing some basic work on a support library for type level programming ( see http://hackage.haskell.org/trac/summer-of-code/ticket/1541 ). I know there have been similar attempts using fundeps ( Edward Kmett showed me some of his work, but I've lost the address... ) but this approach

[Haskell-cafe] Type-level programming [The container problem]

2008-09-28 Thread Andrew Coppin
Aaron Denney wrote: On 2008-09-27, Andrew Coppin [EMAIL PROTECTED] wrote: Ah - so the Prolog programs as type signatures thing is *his* fault?! ;-) No, he merely takes advantage of it. Heh. OK. ;-) By the way... I've seen a lot of type-level programs that allow you to express

Re: [Haskell-cafe] Type-level programming [The container problem]

2008-09-28 Thread Brandon S. Allbery KF8NH
On 2008 Sep 28, at 4:47, Andrew Coppin wrote: By the way... I've seen a lot of type-level programs that allow you to express (and therefore verify) some pretty extreme properties of your code. In other words, you can make the compiler do more checking than it normally would. But the actual

[Haskell-cafe] Type-level Programming

2007-06-22 Thread Vincenz Syntactically
Dear all, Recently I was playing around with encoding matrices in the type-level system. Thereby one can enable the multiplication of matrices. The general idea (which can be read about at ( http://notvincenz.blogspot.com/2007/06/generalized-matrix-multiplication.html) is that there is more

[Haskell-cafe] Type-level programming problem

2007-04-30 Thread Thomas Schilling
Hi, I have a type class similar to this one. data T class Foo ns a b c | ns - a, ns - b, ns - c where mkFoo :: ns defaultA :: a defaultB :: c - IO b defaultC :: [T] - c f :: c - b - a - (b, Int) The idea is, that I define classes of components where the data types of the

[Haskell-cafe] Type-level programming problem

2007-04-30 Thread oleg
Thomas Schilling wrote: data T class Foo ns a b c | ns - a, ns - b, ns - c where mkFoo :: ns defaultA :: a defaultB :: c - IO b defaultC :: [T] - c f :: c - b - a - (b, Int) data DefaultA instance Foo ns a b c = Apply DefaultA ns a where apply _ _ =

[Haskell-cafe] Type level programming to eliminate array bound checking, a real world use

2007-04-10 Thread Vivian McPhail
Hi All,Inspired by Oleg's Eliminating Array Bound Checking through Non-dependent types http://okmij.org/ftp/Haskell/types.html#branding,I am attempting to write code that will receive an array from C land and convert it to a type safe representation. The array could have n dimensions where n