Changes between Version 25 and Version 26 of DefaultSuperclassInstances
 Timestamp:
 May 28, 2013 9:53:39 AM (4 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

DefaultSuperclassInstances
v25 v26 88 88 === Default superclass instances === 89 89 90 First, we allow a class declaration to include a '''default superclass instance declaration''' for some, none, or all of its superclass constraints . We say that superclasseswith default implementations are '''intrinsic''' superclasses. Example:90 First, we allow a class declaration to include a '''default superclass instance declaration''' for some, none, or all of its superclass constraints (transitively). We say that superclasses (transitively) with default implementations are '''intrinsic''' superclasses. Example: 91 91 {{{ 92 92 class Functor f => Applicative f where … … 110 110 }}} 111 111 Here, `Applicative` is an intrinsic superclass of `Monad`. 112 113 We might also want to give a different implementation of `fmap` for monads than the 114 one generated by the `Applicative` class declaration: 115 {{{ 116 class Applicative f => Monad f where 117 (>>=) :: f a > (a > f b) > f b 118 instance Applicative f where 119 hiding instance Functor 120 ff <*> fs = ff >>= \ f > fs >>= \ s > return (f s) 121 instance Functor f where 122 fmap f x = x >>= \y > return (f y) 123 }}} 124 (In fact this `fmap` would, after optimisation of a particular instance and if enough inlining too place, generate the same code, but that might not always be the case.) 112 125 113 126 === Instance declarations ===