diff options
author | Max Bolingbroke <batterseapower@hotmail.com> | 2011-09-06 09:04:37 +0100 |
---|---|---|
committer | Max Bolingbroke <batterseapower@hotmail.com> | 2011-09-09 08:26:59 +0100 |
commit | de8c8d68cabb5f24304fad2f03caa41fdf182b4f (patch) | |
tree | 88e191e91aebad8ce2a2ef2bb467be73e0c4d063 /compiler/iface/BinIface.hs | |
parent | 967633d4175a1d5ce525fa3194f53c219b5e2f91 (diff) | |
download | haskell-de8c8d68cabb5f24304fad2f03caa41fdf182b4f.tar.gz |
Implement associated type defaults
Basically, now you can write:
class Cls a where
type Typ a
type Typ a = Just a
And now if an instance does not specify an explicit associated type
instance, one will be generated afresh based on that default. So for
example this instance:
instance Cls Int where
Will be equivalent to this one:
instance Cls Int where
type Typ Int = Just Int
Diffstat (limited to 'compiler/iface/BinIface.hs')
-rw-r--r-- | compiler/iface/BinIface.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/iface/BinIface.hs b/compiler/iface/BinIface.hs index 26b3d9c886..c9c9918cdc 100644 --- a/compiler/iface/BinIface.hs +++ b/compiler/iface/BinIface.hs @@ -1456,6 +1456,21 @@ instance Binary IfaceConDecl where a10 <- get bh return (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10) +instance Binary IfaceAT where + put_ bh (IfaceAT dec defs) = do + put_ bh dec + put_ bh defs + get bh = do dec <- get bh + defs <- get bh + return (IfaceAT dec defs) + +instance Binary IfaceATDefault where + put_ bh (IfaceATD tvs pat_tys ty) = do + put_ bh tvs + put_ bh pat_tys + put_ bh ty + get bh = liftM3 IfaceATD (get bh) (get bh) (get bh) + instance Binary IfaceClassOp where put_ bh (IfaceClassOp n def ty) = do put_ bh (occNameFS n) |