You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-10Lines changed: 15 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
1
# purescript-openlayers
2
2
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!
3
3
4
+
5
+
Version 0.2 supports purescript 0.14.
6
+
7
+
4
8
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.
or make a local addition and clone the repository. Then install it with:
24
+
Then install it with:
21
25
22
26
23
27
```sh
@@ -26,7 +30,7 @@ spago install openlayers
26
30
27
31
## Documentation
28
32
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
30
34
in those cases where the FFI binding differs it is written in the purescript files as comments
31
35
and can be generated from the repository with:
32
36
@@ -44,12 +48,13 @@ npm install ol
44
48
```
45
49
46
50
## 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.
48
53
49
54
50
-
In addition to that the following patterns have been used:
55
+
These additional patterns have been used to map the OpenLayers library:
51
56
### 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:
53
58
54
59
```purescript
55
60
foreign import data RawBaseLayer :: Type -> Type
@@ -62,12 +67,12 @@ type Layer = BaseLayer RawLayer
62
67
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***.
63
68
64
69
### 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:
66
71
67
72
```purescript
68
73
type OptionalFields = (a::String, b::Boolean)
69
74
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
71
76
create o = runFn1 createImpl (FFI.notNullOrUndefined o)
72
77
```
73
78
```javascript
@@ -81,7 +86,7 @@ exports.createImpl = function (opt) {
81
86
This is an example of how a ***create*** function is mapped to the javascript ***new*** function that takes an options parameter with optional fields.
82
87
83
88
### 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:
85
90
86
91
```purescript
87
92
foreign import data Target :: Type
@@ -98,5 +103,5 @@ create o = ...
98
103
and can then be used such as follows:
99
104
100
105
```purescript
101
-
create { target: target.asId "elementid"}
106
+
create { target: target.asId "<your elementid as a string>"}
0 commit comments