@@ -30,8 +30,10 @@ import Language.PureScript.CodeGen.Common (identToJs)
3030import qualified Language.PureScript.Constants as C
3131
3232import Control.Applicative
33+import Control.Monad.Error
3334import Control.Monad.State
3435import Control.Arrow (first, second)
36+import Data.Monoid ((<>))
3537import Data.Maybe (catMaybes)
3638
3739import qualified Data.Map as M
@@ -166,7 +168,8 @@ typeInstanceDictionaryDeclaration name mn deps className tys decls = do
166168 -- Replace the type arguments with the appropriate types in the member types
167169 let memberTypes = map (second (replaceAllTypeVars (zip args tys))) instanceTys
168170 -- Create values for the type instance members
169− memberNames <- map (first identToProperty) <$> mapM (memberToNameAndValue memberTypes) decls
171+ memberNames <- rethrow (strMsg ("Error in type class " ++ show className ++ ":") <>) $
172+ map (first identToProperty) <$> mapM (memberToNameAndValue memberTypes) decls
170173 -- Create the type of the dictionary
171174 -- The type is an object type, but depending on type instance dependencies, may be constrained.
172175 -- The dictionary itself is an object literal, but for reasons related to recursion, the dictionary
@@ -188,7 +191,7 @@ typeInstanceDictionaryDeclaration name mn deps className tys decls = do
188191
189192 memberToNameAndValue :: [(Ident, Type)] -> Declaration -> Desugar (Ident, Value)
190193 memberToNameAndValue tys' d@(ValueDeclaration ident _ _ _ _) = do
191− _ <- lift . maybe (Left $ mkErrorStack "Type class member type not found" Nothing) Right $ lookup ident tys'
194+ _ <- lift . maybe (Left $ mkErrorStack ("Type class does not define member '" ++ show ident ++ "'") Nothing) Right $ lookup ident tys'
192195 let memberValue = typeInstanceDictionaryEntryValue d
193196 return (ident, memberValue)
194197 memberToNameAndValue tys' (PositionedDeclaration pos d) = rethrowWithPosition pos $ do