Skip to content

Commit a1f97fe

Browse files
committed
Use fromRight' instead of lambda
1 parent 5653c67 commit a1f97fe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

recipes/ValueBasedJsonCodecLog/src/Main.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import Data.Codec.Argonaut (JsonCodec, JsonDecodeError(..), printJsonDecodeError
1010
import Data.Codec.Argonaut as CA
1111
import Data.Codec.Argonaut.Common as CAM
1212
import Data.Codec.Argonaut.Record as CAR
13-
import Data.Either (Either(..), either)
13+
import Data.Either (Either(..), either, fromRight')
1414
import Data.Int as Int
1515
import Data.Maybe (Maybe(..))
1616
import Data.Profunctor (dimap)
1717
import Data.String (splitAt)
1818
import Data.TraversableWithIndex (forWithIndex)
1919
import Effect (Effect)
2020
import Effect.Console (log, logShow)
21-
import Partial.Unsafe (unsafePartial)
21+
import Partial.Unsafe (unsafeCrashWith, unsafePartial)
2222

2323
main :: Effect Unit
2424
main = do
@@ -47,7 +47,7 @@ main = do
4747
log $ stringify $ encode entireRecordCodec exampleValue
4848

4949
exampleJson :: Json
50-
exampleJson = unsafePartial $ (\(Right json) -> json) $ jsonParser
50+
exampleJson = unsafePartial $ (fromRight' \_ -> unsafeCrashWith "got Left: bad parser") $ jsonParser
5151
"""
5252
{
5353
"string":"string value",

0 commit comments

Comments
 (0)