Skip to content

Commit b47cf74

Browse files
committed
Expose Options constructor
Resolves #17
1 parent df145aa commit b47cf74

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Data/Options.purs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Data.Options
2-
( Options
3-
, runOptions
2+
( Options(..)
43
, options
54
, Option
65
, assoc, (:=)
@@ -15,7 +14,7 @@ import Prelude
1514
import Data.Foreign (toForeign, Foreign)
1615
import Data.Maybe (Maybe, maybe)
1716
import Data.Monoid (mempty, class Monoid)
18-
import Data.Newtype (unwrap)
17+
import Data.Newtype (class Newtype, unwrap)
1918
import Data.Op (Op(..))
2019
import Data.StrMap as StrMap
2120
import Data.Tuple (Tuple(..))
@@ -25,8 +24,7 @@ import Data.Tuple (Tuple(..))
2524
-- | API are not accidentally passed to some other API.
2625
newtype Options opt = Options (Array (Tuple String Foreign))
2726

28-
runOptions :: forall opt. Options opt -> Array (Tuple String Foreign)
29-
runOptions (Options xs) = xs
27+
derive instance newtypeOptions :: Newtype (Options opt) _
3028

3129
instance semigroupOptions :: Semigroup (Options opt) where
3230
append (Options xs) (Options ys) = Options (xs <> ys)
@@ -37,7 +35,7 @@ instance monoidOptions :: Monoid (Options opt) where
3735
-- | Convert an `Options` value into a JavaScript object, suitable for passing
3836
-- | to JavaScript APIs.
3937
options :: forall opt. Options opt -> Foreign
40-
options = toForeign <<< StrMap.fromFoldable <<< runOptions
38+
options (Options os) = toForeign (StrMap.fromFoldable os)
4139

4240
-- | An `Option` represents an opportunity to configure a specific attribute
4341
-- | of a call to some API. This normally corresponds to one specific property

0 commit comments

Comments
 (0)