Instancia de clase de un sinónimo de tipo

El siguiente código

{-# LANGUAGE TypeSynonymInstances, FlexibleInstances  #-}

module Function where

import qualified Data.Vector.Unboxed as V
import Control.Monad

type Function = V.Vector Double

instance Num Function where
  (+) = liftM2 (+)
  (*) = liftM2 (*)
  negate = fmap negate

returns errors like

No instance for (Monad V.Vector)
  arising from a use of `liftM2'

though it is said in the documentation that Vector is an instance of Monad.

preguntado el 10 de marzo de 12 a las 15:03

FYI, you may have meant zipWith (+) for your instance of (+). I can't tell what you're actually trying to do, though. -

1 Respuestas

sin embalaje Vector no es una instancia de Monad. Notice the vector package exports many different types that are all called Vector. Data.Vector.Unboxed.Vector /= Data.Vector.Vector /= Data.Vector.Storable.Vector.

respondido 10 mar '12, 15:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.