Skip to content

Commit

Permalink
Fix broken test
Browse files Browse the repository at this point in the history
It would be nice if we had a better way of handling "decoders"
that can't fail
  • Loading branch information
aij committed Jun 27, 2019
1 parent 63f928b commit 157fc7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion samples/SelfContained.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module SelfContained {
type Bunnies: wrap Int
<purs
t="Test.Support.Newint"
decode="Data.Newtype.wrap"
decode="Ccap.Codegen.Runtime.decodeNewtype"
encode="Data.Newtype.unwrap">

type County: {
Expand Down
5 changes: 4 additions & 1 deletion src/Ccap/Codegen/Runtime.purs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,15 @@ codec_custom
-> Codec a t
codec_custom decode encode = composeCodec { decode, encode }

decodeNewtype :: forall t a. Newtype t a => a -> Either String t
decodeNewtype a = Right $ wrap a

codec_newtype
:: forall t a b
. Newtype t b
=> Codec a b
-> Codec a t
codec_newtype = composeCodec
{ decode: Right <<< wrap
{ decode: decodeNewtype
, encode: unwrap
}

0 comments on commit 157fc7b

Please sign in to comment.