git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
replace JS code generated by desugarer for typeclasses with PS code (2)
03fae82osa1
src/Language/PureScript/Environment.hs+5−5
@@ -73,11 +73,7 @@ data ForeignImportType
73 -- |
73 -- |
74 -- A foreign import which contains inline Javascript as a string literal
74 -- A foreign import which contains inline Javascript as a string literal
75 --
75 --
76− | InlineJavascript
77− -- |
78− -- A type class dictionary member accessor import, generated during desugaring of type class declarations
79− --
80− | TypeClassAccessorImport deriving (Show, Eq, Data, Typeable)
76+ | InlineJavascript deriving (Show, Eq, Data, Typeable)
81
77
82-- |
78-- |
83-- The kind of a name
79-- The kind of a name
@@ -88,6 +84,10 @@ data NameKind
88 --
84 --
89 = Value
85 = Value
90 -- |
86 -- |
87+ -- A type class dictionary member accessor import, generated during desugaring of type class declarations
88+ --
89+ | TypeClassAccessorImport
90+ -- |
91 -- A foreign import
91 -- A foreign import
92 --
92 --
93 | Extern ForeignImportType
93 | Extern ForeignImportType
src/Language/PureScript/Sugar/TypeClasses.hs+3−3
@@ -143,9 +143,9 @@ typeClassDictionaryDeclaration name args implies members =
143
143
144typeClassMemberToDictionaryAccessor :: ModuleName -> ProperName -> [String] -> Declaration -> Declaration
144typeClassMemberToDictionaryAccessor :: ModuleName -> ProperName -> [String] -> Declaration -> Declaration
145typeClassMemberToDictionaryAccessor mn name args (TypeDeclaration ident ty) =
145typeClassMemberToDictionaryAccessor mn name args (TypeDeclaration ident ty) =
146− ExternDeclaration TypeClassAccessorImport ident
146+ ValueDeclaration ident TypeClassAccessorImport [] Nothing $
147− (Just (JSFunction (Just $ identToJs ident) ["dict"] (JSBlock [JSReturn (JSIndexer (JSStringLiteral (identToProperty ident)) (JSVar "dict"))])))
147+ TypedValue False (Abs (Left $ Ident "dict") (Accessor (runIdent ident) (Var $ Qualified Nothing (Ident "dict")))) $
148− (moveQuantifiersToFront (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"