git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Code comments
4dc1c58Phil Freeman
src/Language/PureScript/Sugar/TypeClasses.hs+21
@@ -70,6 +70,14 @@ desugarModule _ = error "Exports should have been elaborated in name desugaring"
70-- instance fooArray :: (Foo a) => Foo [a] where
70-- instance fooArray :: (Foo a) => Foo [a] where
71-- foo = map foo
71-- foo = map foo
72--
72--
73+-- {- Superclasses -}
74+--
75+-- class (Foo a) <= Sub a where
76+-- sub :: a
77+--
78+-- instance subString :: Sub String where
79+-- sub = ""
80+--
73-- becomes
81-- becomes
74--
82--
75-- type Foo a = { foo :: a -> a }
83-- type Foo a = { foo :: a -> a }
@@ -84,6 +92,19 @@ desugarModule _ = error "Exports should have been elaborated in name desugaring"
84-- fooArray :: forall a. (Foo a) => Foo [a]
92-- fooArray :: forall a. (Foo a) => Foo [a]
85-- fooArray = { foo: map foo }
93-- fooArray = { foo: map foo }
86--
94--
95+-- {- Superclasses -}
96+--
97+-- ...
98+--
99+-- subString :: {} -> { __superclasses :: [{}], sub :: String }
100+-- subString _ = {
101+-- __superclasses: [\<dictionary placeholder to be inserted during type checking\>]
102+-- sub: ""
103+-- }
104+--
105+-- Here, the __superclasses property is not typechecked (it is not even well-typed, since its
106+-- entries might be dictionaries of different types).
107+--
87desugarDecl :: ModuleName -> Declaration -> Desugar (Maybe DeclarationRef, [Declaration])
108desugarDecl :: ModuleName -> Declaration -> Desugar (Maybe DeclarationRef, [Declaration])
88desugarDecl mn d@(TypeClassDeclaration name args _ members) = do
109desugarDecl mn d@(TypeClassDeclaration name args _ members) = do
89 modify (M.insert (mn, name) d)
110 modify (M.insert (mn, name) d)