Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplify code for encoding of Either
  • Loading branch information
csicar committed Sep 24, 2020
commit 989eee8a3d52b852bf9033c224018ec244bc8098
4 changes: 2 additions & 2 deletions src/Foreign/Generic/Class.purs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ instance maybeEncode :: Encode a => Encode (Maybe a) where

instance eitherEncode :: (Encode a, Encode b) => Encode (Either a b) where
encode = case _ of
Left value -> unsafeToForeign $ Record.insert (SProxy:: SProxy "Left") (encode value) {}
Right value -> unsafeToForeign $ Record.insert (SProxy:: SProxy "Right") (encode value) {}
Left value -> unsafeToForeign $ {"Left": encode value }
Right value -> unsafeToForeign $ { "Right": encode value }

instance tupleEncode :: (Encode a, Encode b) => Encode (Tuple a b) where
encode (Tuple a b) = encode [encode a, encode b]
Expand Down