[Haskell-cafe] Question on type synonym definition and language
extensions
Antoine Latter
aslatter at gmail.com
Thu May 29 19:36:31 EDT 2008
2008/5/29 Olivier Boudry <olivier.boudry at gmail.com>:
> After some "read, guess, try, error" cycles I came up with this:
>
> type Matrix = forall m. forall a. forall i. forall n. (Ix i, MArray a n
> m, Num i, Num n) => m (a (i,i) n)
I've tried similar things before. You may run into subtle problems later.
Such as:
> transpose :: Matrix -> Matrix
won't expand into the type signature you want it to, I think.
You probably want that to be equivalent to:
transpose :: forall m. forall a. forall i. forall n. (Ix i, MArray a
n m, Num i, Num n) => m (a (i,i) n) -> m (a (i,i) n)
But you'll get:
transpose :: forall m. forall a. forall i. forall n. (Ix i, MArray a
n m, Num i, Num n) => Matrix -> m (a (i,i) n)
which means that the first argument must be a polymorphic value, which
isn't very useful.
-Antoine
-Antoine
More information about the Haskell-Cafe
mailing list