[Haskell-cafe] Learning GADT types to simulate dependent types

2008-06-28 Thread Paul Johnson
I'm trying to understand how to use GADT types to simulate dependent types. I'm trying to write a version of list that uses Peano numbers in the types to keep track of how many elements are in the list. Like this: {-# OPTIONS -fglasgow-exts -fallow-undecidable-instances #-} module Plist whe

Re: [Haskell-cafe] Learning GADT types to simulate dependent types

2008-06-28 Thread Daniel Fischer
Am Samstag, 28. Juni 2008 19:51 schrieb Paul Johnson: > I'm trying to understand how to use GADT types to simulate dependent > types. I'm trying to write a version of list that uses Peano numbers > in the types to keep track of how many elements are in the list. Like > this: > > {-# OPTIONS -fgl

Re: [Haskell-cafe] Learning GADT types to simulate dependent types

2008-06-28 Thread Dan Doel
On Saturday 28 June 2008, Paul Johnson wrote: > I'm trying to understand how to use GADT types to simulate dependent > types. I'm trying to write a version of list that uses Peano numbers > in the types to keep track of how many elements are in the list. Like > this: > > {-# OPTIONS -fglasgow-ex

Re: [Haskell-cafe] Learning GADT types to simulate dependent types

2008-06-28 Thread Paul Johnson
Daniel Fischer wrote: My Oleg rating isn't high either, and certainly you can do it more elegant, but class Concat l1 l2 l3 | l1 l2 -> l3, l1 l3 -> l2 where pConcat :: l1 a -> l2 a -> l3 a instance Concat (Plist Zero) (Plist n) (Plist n) where pConcat _ ys = ys instance Concat (Pli