| | 205 | |
| | 206 | [[br]] |
| | 207 | |
| | 208 | == !InstanceDecl == |
| | 209 | |
| | 210 | {{{ |
| | 211 | InstanceDecl |
| | 212 | ::= instance Con SimpleType+ where { Binding;+ } |
| | 213 | }}} |
| | 214 | |
| | 215 | [[br]] |
| | 216 | |
| | 217 | == !ProjectionDecl == |
| | 218 | |
| | 219 | {{{ |
| | 220 | ProjectionDecl |
| | 221 | ::= project Con SimpleType* where { (TypeSig|Binding)+ } -- projection dictionary |
| | 222 | | project Con SimpleType* with { Var+ } -- projection punning |
| | 223 | }}} |
| | 224 | |
| | 225 | The first form defines some projection functions associated with a given type. Presently, all projections associated with a type must be declared in the same projection declaration and in the same source module, but there is a plan to relax this #7. |
| | 226 | |
| | 227 | If two projection dictionaries are defined for types that overlap, eg List Int and List a, then the result is currently undefined. There is a ticket to fix this #40. |
| | 228 | |
| | 229 | The projection punning syntax imports bindings at top level into the projection name space. For example: |
| | 230 | |
| | 231 | {{{ |
| | 232 | project Set a with { insert; delete; size } |
| | 233 | }}} |
| | 234 | |
| | 235 | Is equivalent to |
| | 236 | {{{ |
| | 237 | project Set a where { insert = insert; delete = delete; size = size } |
| | 238 | }}} |
| | 239 | |
| | 240 | This is useful when implementations of {{{insert}}}, {{{delete}}} and {{{size}}} are in the current module, but only the type {{{Set}}} is exported. All projections associated with a certain type are exported when the type is. |
| | 241 | |
| | 242 | |
| | 243 | == !TypeSig == |
| | 244 | |
| | 245 | {{{ |
| | 246 | TypeSig |
| | 247 | ::= Var :: Type |
| | 248 | }}} |
| | 249 | |
| | 250 | |