1
1
module Data.Options
2
- ( Options
3
- , runOptions
2
+ ( Options (..)
4
3
, options
5
4
, Option
6
5
, assoc , (:=)
@@ -15,7 +14,7 @@ import Prelude
15
14
import Data.Foreign (toForeign , Foreign )
16
15
import Data.Maybe (Maybe , maybe )
17
16
import Data.Monoid (mempty , class Monoid )
18
- import Data.Newtype (unwrap )
17
+ import Data.Newtype (class Newtype , unwrap )
19
18
import Data.Op (Op (..))
20
19
import Data.StrMap as StrMap
21
20
import Data.Tuple (Tuple (..))
@@ -25,8 +24,7 @@ import Data.Tuple (Tuple(..))
25
24
-- | API are not accidentally passed to some other API.
26
25
newtype Options opt = Options (Array (Tuple String Foreign ))
27
26
28
- runOptions :: forall opt . Options opt -> Array (Tuple String Foreign )
29
- runOptions (Options xs) = xs
27
+ derive instance newtypeOptions :: Newtype (Options opt ) _
30
28
31
29
instance semigroupOptions :: Semigroup (Options opt ) where
32
30
append (Options xs) (Options ys) = Options (xs <> ys)
@@ -37,7 +35,7 @@ instance monoidOptions :: Monoid (Options opt) where
37
35
-- | Convert an `Options` value into a JavaScript object, suitable for passing
38
36
-- | to JavaScript APIs.
39
37
options :: forall opt . Options opt -> Foreign
40
- options = toForeign <<< StrMap .fromFoldable <<< runOptions
38
+ options ( Options os) = toForeign ( StrMap .fromFoldable os)
41
39
42
40
-- | An `Option` represents an opportunity to configure a specific attribute
43
41
-- | of a call to some API. This normally corresponds to one specific property
0 commit comments