OK I'll include the module after I change the things mentioned. BTW, I finally have an initial version of the parameterized-data package:
Darcs repository: http://code.haskell.org/parameterized-data Haddock documentation: http://code.haskell.org/~fons/parameterized-data/doc/ Any comments/suggestions would be appreciated. To fix the problem of the "vector" constructor I included a Template Haskell variant. It is quite simple to use: $ ghci -XTemplateHaskell Prelude> :m +Data.Param Prelude Data.Param> $(vectorTH [1 :: Int, 2, 3, 4]) Prelude Data.Param> :t $(vectorTH [1 :: Int, 2, 3, 4]) (vectorTH [1 :: Int, 2, 3, 4]) :: (Num t) => FSVec Data.TypeLevel.Num.Reps.D4 t Note that the size parameter (type-level decimal numeral) is correct. It would be nice to be able to use a Quasiquoter [1] (available in GHC HEAD) to enable pattern matching and custom syntax to Vector literals. However, I was bitten by a polymorphism problem when implementing it: see [2] for details [1] http://www.haskell.org/ghc/dist/current/docs/users_guide/template-haskell.html#th-quasiquotation [2] http://www.haskell.org/pipermail/template-haskell/2008-February/000655.html On Wed, Feb 20, 2008 at 2:26 AM, Wolfgang Jeltsch <[EMAIL PROTECTED]> wrote: > Am Mittwoch, 20. Februar 2008 00:39 schrieben Sie: > > > Why are the value-level reflecting functionsimplemented as type-class > > methods? It makes the code more verbose and I don't see any advantage > > compared to simply defining a function per class. Let me show you an > > example: > > > > This is your implementation of Not: > > > > class (Boolean boolean, Boolean boolean') => > > Not boolean boolean' | boolean -> boolean', boolean' -> boolean > > where not :: boolean -> boolean' > > > > instance Not False True where > > not _ = true > > > > instance Not True False where > > not _ = false > > > > This is how I would do it: > > > > class (Boolean boolean, Boolean boolean') => > > Not boolean boolean' | boolean -> boolean', boolean' -> boolean > > where > > > > instance Not False True > > instance Not True False > > > > not :: Not a b => a -> b > > not = undefined > > Your definition of the not function uses the implementation detail that false > and true are actually undefined. My implementation of the not function also > works if false and true are defined to be something different. Of course, > false and true are in the same library, so we know this implementation detail > and could make use of it. > > > > Furthermore, why did you choose to use Boolean instead of simply Bool? > > To avoid a name clash. Feel free to change this. > > Note that False and True don't cause a name clash since they live in a > namespace different from the one Prelude's False and True live in. > > > Cheers, > > > > Fons > > > > Best wishes, > Wolfgang > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe