git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
replace JS code generated by desugarer for typeclasses with PS code (2)
commit03fae828ab3c68f98e02f25c86cf69e93af961bf authorosa1 <omeragacan@gmail.com> dateWed 30 Apr 2014, 20:09 (13 years ago) parent432f614
2 files changed+8−8
src/Language/PureScript/Environment.hs+5−5 src/Language/PureScript/Sugar/TypeClasses.hs+3−3
src/Language/PureScript/Environment.hs+5−5
@@ -73,11 +73,7 @@ data ForeignImportType
7373 -- |
7474 -- A foreign import which contains inline Javascript as a string literal
7575 --
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)
8177
8278-- |
8379-- The kind of a name
@@ -88,6 +84,10 @@ data NameKind
8884 --
8985 = Value
9086 -- |
87+ -- A type class dictionary member accessor import, generated during desugaring of type class declarations
88+ --
89+ | TypeClassAccessorImport
90+ -- |
9191 -- A foreign import
9292 --
9393 | Extern ForeignImportType
src/Language/PureScript/Sugar/TypeClasses.hs+3−3
@@ -143,9 +143,9 @@ typeClassDictionaryDeclaration name args implies members =
143143
144144typeClassMemberToDictionaryAccessor :: ModuleName -> ProperName -> [String] -> Declaration -> Declaration
145145typeClassMemberToDictionaryAccessor mn name args (TypeDeclaration ident ty) =
146− ExternDeclaration TypeClassAccessorImport ident
147− (Just (JSFunction (Just $ identToJs ident) ["dict"] (JSBlock [JSReturn (JSIndexer (JSStringLiteral (identToProperty ident)) (JSVar "dict"))])))
148− (moveQuantifiersToFront (quantify (ConstrainedType [(Qualified (Just mn) name, map TypeVar args)] ty)))
146+ ValueDeclaration ident TypeClassAccessorImport [] Nothing $
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))
149149typeClassMemberToDictionaryAccessor mn name args (PositionedDeclaration pos d) =
150150 PositionedDeclaration pos $ typeClassMemberToDictionaryAccessor mn name args d
151151typeClassMemberToDictionaryAccessor _ _ _ _ = error "Invalid declaration in type class definition"