impossible happened: splitTyConApp a{tv i6hr}
Frederik Eaton
frederik at a5.repetae.net
Wed Aug 16 09:52:16 EDT 2006
I've attached the code.
> Skipping Vector ( Vector.hs, dist/build/Vector.o )
> Compiling Vector.General ( ./Vector/General.hs, dist/build/Vector/General.o )
>
> ./Vector/General.hs:29:0:
> Warning: No explicit method nor default method for `vectorUpdate'
> In the instance declaration for `Vector (GVector e) e'
>
> ./Vector/General.hs:29:0:
> Warning: No explicit method nor default method for `byRow'
> In the instance declaration for `Vector (GVector e) e'
> ghc-6.4.2: panic! (the `impossible' happened, GHC version 6.4.2):
> splitTyConApp a{tv i6hr}
>
> Please report this as a compiler bug. See:
> http://www.haskell.org/ghc/reportabug
--
http://ofb.net/~frederik/
-------------- next part --------------
{-# OPTIONS -fglasgow-exts #-}
module Vector.General (
GVector,
useG
) where
import Data.Typeable
import Control.Monad
import Vector.Array
import Vector.Fast
import Vector.Base
--import Vector.GeneralTemplate
data GVector e a where
FV :: FVector a -> GVector R a
AV :: AVector e a -> GVector e a
instance Typeable2 GVector where
typeOf2 _ = mkTyConApp (mkTyCon "GVector") []
mc v x = [| case cast $x of
Just x' -> case (cast $ FV $ $v x') of {Just r -> r; Nothing -> undefined}
Nothing -> AV $ $v $x |]
unF :: (Typeable e, Typeable a) => GVector R a -> GVector e a
unF v = case cast v of {Just r -> r; Nothing -> error "unF"}
instance Typeable e => Vector (GVector e) e where
vector f = case cast f of
Just f -> unF $ FV $ vector f
Nothing -> AV $ vector f
-- vectorM f = $(mc [|vectorM|] [|f|])
vectorM f = case cast f of
Just f -> liftM (unF.FV) $ vectorM f
Nothing -> liftM AV $ vectorM f
fromArray ax = case cast ax of
Just ax -> unF $ FV $ fromArray ax
Nothing -> AV $ fromArray ax
toArray (AV v) = toArray v
toArray (FV v) = toArray v
fromList l = case cast l of
Just l -> unF $ FV $ fromList l
Nothing -> AV $ fromList l
(!) (FV v) i = v!i
(!) (AV v) i = v!i
slice f (FV v) = FV $ slice f v
slice f (AV v) = AV $ slice f v
unsafeReshape (FV v) = FV $ unsafeReshape v
unsafeReshape (AV v) = AV $ unsafeReshape v
vconst x = case cast x of
Just x -> unF $ FV $ vconst x
Nothing -> AV $ vconst x
vconcat (FV u) (FV v) = FV $ vconcat u v
vconcat (AV u) (AV v) = AV $ vconcat u v
elems (FV v) = elems v
elems (AV v) = elems v
assocs (FV v) = assocs v
assocs (AV v) = assocs v
fromList2 l = case cast l of
Just l -> unF $ FV $ fromList2 l
Nothing -> AV $ fromList2 l
elems2 (FV m) = elems2 m
elems2 (AV m) = elems2 m
-- | force argument to be a GVector
useG :: GVector e a -> GVector e a
useG v = v
More information about the Glasgow-haskell-bugs
mailing list