Skip to content

Commit b0c4489

Browse files
committed
Updated README
1 parent bc4e194 commit b0c4489

File tree

4 files changed

+1722
-29
lines changed

4 files changed

+1722
-29
lines changed

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# purescript-openlayers
22
A purescript FFI binding for OpenLayers v6.5. It is by no means near a complete binding but fulfills the need for the Swedish IoT Hub Prototype for Accessibility Case 3, see https://github.com/dnulnets/haccessibility, for now. Please feel free to contribute to thie library!
33

4+
5+
Version 0.2 supports purescript 0.14.
6+
7+
48
OpenLayers uses a lot of object inheritance, optional record fields and fields having mutiple types when creating the objects. It has been solved in purescript by using type parameters, Union, and a pattern of constructuor records and unsafeCoerce. See below for more details.
59

610
## Adding the library to your project
@@ -12,12 +16,12 @@ let additions = {
1216
openlayers =
1317
{ dependencies =[ "console", "effect", "foreign", "functions", "maybe", "nullable", "psci-support"]
1418
, repo = "https://github.com/dnulnets/purescript-openlayers.git"
15-
, version = "v0.1.9"
19+
, version = "v0.2.0"
1620
}
1721
}
1822
```
1923

20-
or make a local addition and clone the repository. Then install it with:
24+
Then install it with:
2125

2226

2327
```sh
@@ -26,7 +30,7 @@ spago install openlayers
2630

2731
## Documentation
2832

29-
The majority of the documentation is the already on the OpenLayers home page for javascript and
33+
The majority of the documentation is already on the OpenLayers home page for javascript and
3034
in those cases where the FFI binding differs it is written in the purescript files as comments
3135
and can be generated from the repository with:
3236

@@ -44,12 +48,13 @@ npm install ol
4448
```
4549

4650
## Patterns used by the FFI Mapping for OpenLayers
47-
All javascript ***new*** functions in OpenLayers are mapped to a correspondign ***create*** function for each class. The case when the options parameter for the javascript ***new*** function can be omitted completely a ***create'*** function is added.
51+
All javascript ***new*** functions in OpenLayers are mapped to a correspondign ***create*** function for each class. The case when
52+
the options parameter for the javascript ***new*** function can be omitted completely a ***create'*** function is added with no parameters.
4853

4954

50-
In addition to that the following patterns have been used:
55+
These additional patterns have been used to map the OpenLayers library:
5156
### Inheritance
52-
The following pattern is used to follow the inheritance structure for the Openlayers FFI mapping:
57+
The following pattern is used to follow OpenLayers inheritance structure for the Openlayers FFI mapping:
5358

5459
```purescript
5560
foreign import data RawBaseLayer :: Type -> Type
@@ -62,12 +67,12 @@ type Layer = BaseLayer RawLayer
6267
This is an example of a ***Layer*** that "inherits" ***BaseLayer*** and you can then use a ***Layer*** in every function that takes a ***BaseLayer a***.
6368

6469
### Optional record fields
65-
The following pattern is used to support optional record fields within OpenLayers:
70+
The following pattern is used to support optional record fields within OpenLayers but still have a control of what fields are allowed within purescript:
6671

6772
```purescript
6873
type OptionalFields = (a::String, b::Boolean)
6974
70-
create :: forall l r . Union l r OptionalFields => Record l -> Effect ....
75+
create :: forall l r . Union l r OptionalFields => Record l -> Effect Vector
7176
create o = runFn1 createImpl (FFI.notNullOrUndefined o)
7277
```
7378
```javascript
@@ -81,7 +86,7 @@ exports.createImpl = function (opt) {
8186
This is an example of how a ***create*** function is mapped to the javascript ***new*** function that takes an options parameter with optional fields.
8287

8388
### Record fields with multiple types
84-
The following pattern is used to support record fields that can have multiple types within OpenLayers:
89+
The following pattern is used to support record fields that can have multiple types within OpenLayers, this example has the field ***target*** as multiple types:
8590

8691
```purescript
8792
foreign import data Target :: Type
@@ -98,5 +103,5 @@ create o = ...
98103
and can then be used such as follows:
99104

100105
```purescript
101-
create { target: target.asId "elementid"}
106+
create { target: target.asId "<your elementid as a string>"}
102107
```

0 commit comments

Comments
 (0)