On Sun, Sep 12, 2010 at 9:24 AM, Dominique Devriese <dominique.devri...@cs.kuleuven.be> wrote: >> However, it would make more sense to have it be a type family, without >> the overhead of data (both in space and in typing). > > You can make Tensor a data family and use "newtype instances". As I > understand these, there should not be a space overhead. The only > overhead I would expect this to introduce is the extra newtype > constructor.
Which is only at programming time; newtype constructors do not exist at runtime. They get erased after typechecking. This also means that pattern matching against newtype constructors cannot fail. For example: > data family F a > data instance F Bool = B () > newtype instance F Int = I () > > fBool :: F Bool -> Int > f1 (B _) = 3 > > fInt :: F Int -> Int > f2 (I _) = 4 > > main = do > print (fInt undefined) > print (fBool undefined) This program should print 4 and then exit with an error. -- ryan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe