-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJSClass.purs
More file actions
20 lines (16 loc) · 842 Bytes
/
JSClass.purs
File metadata and controls
20 lines (16 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module JS.JSClass where
import Control.Category ((<<<))
import JS.Object (class ConstrFn, new)
import Unsafe.Coerce (unsafeCoerce)
-- | JSClass contains:
-- | * constructor type (please check `JS.JSObject.ConstructorEffectFn*`) families of
-- | functions. They encode the final instance object shape as well.
-- | * row of static methods and properties.
-- |
-- | This is simplified view on classes and instances from JS land. We don't care about
-- | providing direct support for `this.constructor`, `this.prototype` etc.
-- | On the other hand it is pretty easy to provide generic helpers or perform
-- | codegen to this representation.
foreign import data JSClass :: Type -> Row Type -> Type
instance (ConstrFn constr constrFn) => ConstrFn (JSClass constr c) constrFn where
new = new <<< (unsafeCoerce :: JSClass constr c -> constr)