@@ -27,6 +27,8 @@ import Language.PureScript.Environment
27import Language.PureScript.Errors
27import Language.PureScript.Errors
28import Language.PureScript.CodeGen.Common (identToJs)
28import Language.PureScript.CodeGen.Common (identToJs)
30+import qualified Language.PureScript.Constants as C
30import Control.Applicative
32import Control.Applicative
31import Control.Monad.State
33import Control.Monad.State
32import Control.Arrow (first, second)
34import Control.Arrow (first, second)
@@ -164,9 +166,12 @@ typeInstanceDictionaryDeclaration name mn deps className tys decls = do
164 -- The dictionary itself is an object literal, but for reasons related to recursion, the dictionary
166 -- The dictionary itself is an object literal, but for reasons related to recursion, the dictionary
165 -- must be guarded by at least one function abstraction. For that reason, if the dictionary has no
167 -- must be guarded by at least one function abstraction. For that reason, if the dictionary has no
166 -- dependencies, we introduce an unnamed function parameter.
168 -- dependencies, we introduce an unnamed function parameter.
169+ let (memberTypes', memberNames') =
171+ then (memberTypes, memberNames)
172+ else ((Ident C.__superclasses, TypeApp tyArray unit) : memberTypes, (C.__superclasses, superclasses) : memberNames)
167− let dictTy = TypeApp tyObject (rowFromList (map (first identToProperty) memberTypes, RCons "__superclasses" (TypeApp tyArray unit) REmpty))
173+ dictTy = TypeApp tyObject (rowFromList (map (first identToProperty) memberTypes', REmpty))
168 constrainedTy = quantify (if null deps then function unit dictTy else ConstrainedType deps dictTy)
174 constrainedTy = quantify (if null deps then function unit dictTy else ConstrainedType deps dictTy)
169− memberNames' = ("__superclasses", superclasses) : memberNames
170 dict = if null deps then Abs (Left (Ident "_")) (ObjectLiteral memberNames') else ObjectLiteral memberNames'
175 dict = if null deps then Abs (Left (Ident "_")) (ObjectLiteral memberNames') else ObjectLiteral memberNames'
171 return $ ValueDeclaration name TypeInstanceDictionaryValue [] Nothing (TypedValue True dict constrainedTy)
176 return $ ValueDeclaration name TypeInstanceDictionaryValue [] Nothing (TypedValue True dict constrainedTy)