@@ -145,7 +145,7 @@ typeClassMemberToDictionaryAccessor :: ModuleName -> ProperName -> [String] -> D
145typeClassMemberToDictionaryAccessor mn name args (TypeDeclaration ident ty) =
145typeClassMemberToDictionaryAccessor mn name args (TypeDeclaration ident ty) =
146 ExternDeclaration TypeClassAccessorImport ident
146 ExternDeclaration TypeClassAccessorImport ident
147 (Just (JSFunction (Just $ identToJs ident) ["dict"] (JSBlock [JSReturn (JSIndexer (JSStringLiteral (identToProperty ident)) (JSVar "dict"))])))
147 (Just (JSFunction (Just $ identToJs ident) ["dict"] (JSBlock [JSReturn (JSIndexer (JSStringLiteral (identToProperty ident)) (JSVar "dict"))])))
148− (quantify (ConstrainedType [(Qualified (Just mn) name, map TypeVar args)] ty))
148+ (moveQuantifiersToFront (quantify (ConstrainedType [(Qualified (Just mn) name, map TypeVar args)] ty)))
149typeClassMemberToDictionaryAccessor mn name args (PositionedDeclaration pos d) =
149typeClassMemberToDictionaryAccessor mn name args (PositionedDeclaration pos d) =
150 PositionedDeclaration pos $ typeClassMemberToDictionaryAccessor mn name args d
150 PositionedDeclaration pos $ typeClassMemberToDictionaryAccessor mn name args d
151typeClassMemberToDictionaryAccessor _ _ _ _ = error "Invalid declaration in type class definition"
151typeClassMemberToDictionaryAccessor _ _ _ _ = error "Invalid declaration in type class definition"
@@ -169,7 +169,7 @@ typeInstanceDictionaryDeclaration name mn deps className tys decls =
169 case mapMaybe declName tyDecls \\ mapMaybe declName decls of
169 case mapMaybe declName tyDecls \\ mapMaybe declName decls of
170 x : _ -> throwError $ mkErrorStack ("Member '" ++ show x ++ "' has not been implemented") Nothing
170 x : _ -> throwError $ mkErrorStack ("Member '" ++ show x ++ "' has not been implemented") Nothing
173 let instanceTys = map memberToNameAndType tyDecls
173 let instanceTys = map memberToNameAndType tyDecls
175 -- Replace the type arguments with the appropriate types in the member types
175 -- Replace the type arguments with the appropriate types in the member types
@@ -192,16 +192,16 @@ typeInstanceDictionaryDeclaration name mn deps className tys decls =
192 dictTy = foldl TypeApp (TypeConstructor className) tys
192 dictTy = foldl TypeApp (TypeConstructor className) tys
193 constrainedTy = quantify (if null deps then function unit dictTy else ConstrainedType deps dictTy)
193 constrainedTy = quantify (if null deps then function unit dictTy else ConstrainedType deps dictTy)
194 dict = if null deps then Abs (Left (Ident "_")) (ObjectLiteral memberNames') else ObjectLiteral memberNames'
194 dict = if null deps then Abs (Left (Ident "_")) (ObjectLiteral memberNames') else ObjectLiteral memberNames'
196 return $ ValueDeclaration name TypeInstanceDictionaryValue [] Nothing (TypedValue True dict constrainedTy)
196 return $ ValueDeclaration name TypeInstanceDictionaryValue [] Nothing (TypedValue True dict constrainedTy)
200 declName :: Declaration -> Maybe Ident
200 declName :: Declaration -> Maybe Ident
201 declName (PositionedDeclaration _ d) = declName d
201 declName (PositionedDeclaration _ d) = declName d
202 declName (ValueDeclaration ident _ _ _ _) = Just ident
202 declName (ValueDeclaration ident _ _ _ _) = Just ident
203 declName (TypeDeclaration ident _) = Just ident
203 declName (TypeDeclaration ident _) = Just ident
204− declName _ = Nothing
204+ declName _ = Nothing
206 memberToNameAndValue :: [(Ident, Type)] -> Declaration -> Desugar (Ident, Value)
206 memberToNameAndValue :: [(Ident, Type)] -> Declaration -> Desugar (Ident, Value)
207 memberToNameAndValue tys' d@(ValueDeclaration ident _ _ _ _) = do
207 memberToNameAndValue tys' d@(ValueDeclaration ident _ _ _ _) = do