@@ -7,19 +7,19 @@ import Data.Either (Either(..))
7
7
import Data.Foldable (traverse_ )
8
8
import Data.List as List
9
9
import Data.List.Lazy as LazyList
10
+ import Data.Map as Map
10
11
import Data.Maybe (Maybe (..))
11
12
import Data.Newtype (class Newtype , un )
12
13
import Data.Nullable as Nullable
13
14
import Data.Tuple (Tuple (..))
14
15
import Data.Tuple.Nested ((/\))
15
16
import Data.Variant (Variant , inj )
16
- import Debug (spy )
17
17
import Foreign.Object as Object
18
- import Test.Spec (Spec , describe , it , itOnly )
18
+ import Test.Spec (Spec , describe , it )
19
19
import Test.Spec.Assertions (shouldEqual )
20
20
import Test.Util (roundtrips )
21
21
import Type.Proxy (Proxy (..))
22
- import Yoga.JSON (class ReadForeign , class WriteForeign , readJSON , readJSON_ , writeJSON )
22
+ import Yoga.JSON (class ReadForeign , class WriteForeign , readJSON , writeJSON )
23
23
import Yoga.JSON.Variant (TaggedVariant (..), UntaggedVariant (..))
24
24
25
25
spec :: Spec Unit
@@ -45,6 +45,12 @@ spec = describe "En- and decoding" $ do
45
45
it " roundtrips List" $ traverse_ roundtrips (List .fromFoldable [[" A" , " B" ],[]] )
46
46
it " roundtrips NonEmptyArray" $ roundtrips (NEA .cons' " A" [" B" ])
47
47
it " roundtrips Object" $ roundtrips (Object .fromHomogeneous { a: 12 , b: 54 })
48
+ it " roundtrips String Map" $ roundtrips (Map .fromFoldable [(" A" /\ 8 ),(" C" /\ 7 )] )
49
+ it " roundtrips Int Map" $ roundtrips (Map .fromFoldable [(4 /\ " B" ),(8 /\ " D" )] )
50
+ it " roundtrips Map with String newtype keys"
51
+ $ roundtrips (Map .fromFoldable [(Stringy " A" /\ " B" ),(Stringy " C" /\ " D" )] )
52
+ it " roundtrips Map with Int newtype keys"
53
+ $ roundtrips (Map .fromFoldable [(Inty 4 /\ " B" ),(Inty 8 /\ " D" )] )
48
54
49
55
describe " works on record types" do
50
56
it " roundtrips" do
@@ -86,12 +92,23 @@ spec = describe "En- and decoding" $ do
86
92
87
93
type ExampleVariant = (" erwin" :: String, " jackie" :: Int)
88
94
type ExampleTaggedVariant t v = TaggedVariant t v ExampleVariant
95
+
96
+ erwin ∷ ∀ a r. a → Variant ( erwin ∷ a | r )
89
97
erwin = inj (Proxy :: Proxy " erwin" )
90
98
type Erwin r = (erwin :: String | r)
91
99
92
100
newtype Stringy = Stringy String
93
101
derive instance Newtype Stringy _
94
102
derive newtype instance Show Stringy
95
103
derive newtype instance Eq Stringy
104
+ derive newtype instance Ord Stringy
96
105
derive newtype instance WriteForeign Stringy
97
- derive newtype instance ReadForeign Stringy
106
+ derive newtype instance ReadForeign Stringy
107
+
108
+ newtype Inty = Inty Int
109
+ derive instance Newtype Inty _
110
+ derive newtype instance Show Inty
111
+ derive newtype instance Eq Inty
112
+ derive newtype instance Ord Inty
113
+ derive newtype instance WriteForeign Inty
114
+ derive newtype instance ReadForeign Inty
0 commit comments