
Those are bittorrent types, as defined by the protocol "specifications"
I was thinking:
data TPrimitive= TString String | TInt Integer
data TComplex = TList [TPrimitive] | TDict [(String,TPrimitive)]
data T = TPrimitive | TComplex
Would that work?
On Wed, Jul 30, 2008 at 16:28, Jason Dusek
A data declaration _defines_ type constructors. You describe what types those constructors can accept, so this:
data T = TString String | TInt Integer | TList [T] | TDict [(TString, T)]
actually doesn't make any sense -- the list holds what? Holds tuples of `TString` and `T`. What type is `TString` ? It's not a type, it's a constructor! So you need to make it a type.
Also, it is not clear to me why the `TDict` can not just map `String`s to `T`s -- if you get a `TString` in the course of parsing, you can unwrap it.
-- _jsn _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc.