git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Code comments
commit4dc1c5819a03cb72fa7aca69b347e9d4cf974606 authorPhil Freeman <paf31@cantab.net> dateSat 5 Apr 2014, 18:14 (13 years ago) parentde77134
1 file changed+21
src/Language/PureScript/Sugar/TypeClasses.hs+21
src/Language/PureScript/Sugar/TypeClasses.hs+21
@@ -70,6 +70,14 @@ desugarModule _ = error "Exports should have been elaborated in name desugaring"
7070-- instance fooArray :: (Foo a) => Foo [a] where
7171-- foo = map foo
7272--
73+-- {- Superclasses -}
74+--
75+-- class (Foo a) <= Sub a where
76+-- sub :: a
77+--
78+-- instance subString :: Sub String where
79+-- sub = ""
80+--
7381-- becomes
7482--
7583-- type Foo a = { foo :: a -> a }
@@ -84,6 +92,19 @@ desugarModule _ = error "Exports should have been elaborated in name desugaring"
8492-- fooArray :: forall a. (Foo a) => Foo [a]
8593-- fooArray = { foo: map foo }
8694--
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+--
87108desugarDecl :: ModuleName -> Declaration -> Desugar (Maybe DeclarationRef, [Declaration])
88109desugarDecl mn d@(TypeClassDeclaration name args _ members) = do
89110 modify (M.insert (mn, name) d)