| | 105 | == The VECTORISE pragma for type classes == |
| | 106 | |
| | 107 | For a type class `C`, the pragma |
| | 108 | {{{ |
| | 109 | {-# VECTORISE class C #-} |
| | 110 | }}} |
| | 111 | indicates that the class `C` should be automatically vectorised, even if it is imported. This is the default for all classes declared in the current module. |
| | 112 | |
| | 113 | The class `C` must be in scope, but it may be imported. 'PData' and 'PRepr' instances are generally not used for type classes and their dictionary representations. |
| | 114 | |
| | 115 | An example is the handling of `Num`. |
| | 116 | |
| | 117 | == The VECTORISE pragma for class instances == |
| | 118 | |
| | 119 | For a class instance `C t`, the pragma |
| | 120 | {{{ |
| | 121 | {-# VECTORISE instance C t #-} |
| | 122 | }}} |
| | 123 | indicates that the class instance `C t` should be automatically vectorised, even if it is imported. This implies that all class methods making up the instance dfun are vectorised separately to combine into a vectorised diun. This is the default for all class instances declared in the current module. |
| | 124 | |
| | 125 | == The VECTORISE SCALAR pragma for class instances == |
| | 126 | |
| | 127 | For a class instance `C t`, the pragma |
| | 128 | {{{ |
| | 129 | {-# VECTORISE SCALAR instance C t #-} |
| | 130 | }}} |
| | 131 | indicates that the instance dfun `C t` should vectorised by proceeding as for `VECTORISE SCALAR` on each individual class method of `C`. |
| | 132 | |
| | 133 | An example is `{-# VECTORISE SCALAR instance Num Int #-}`. |
| | 134 | |