Skip to content

Instantly share code, notes, and snippets.

@heath
Last active December 9, 2019 18:48
Show Gist options
  • Save heath/297e0ae4b1b603221a282a9a1d19ac0f to your computer and use it in GitHub Desktop.
Save heath/297e0ae4b1b603221a282a9a1d19ac0f to your computer and use it in GitHub Desktop.
example of decoding a MisoString into an Either String Aeson.Value
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Miso.String
import qualified Data.Aeson as Aeson
import qualified Data.Text.Lazy.Encoding as E
import qualified Data.Text.Lazy as TL
main :: IO ()
main = do
let myMisoString = "{\"a\": 1}" :: MisoString
myAesonValue =
Aeson.eitherDecode (E.encodeUtf8 $ TL.fromStrict myMisoString)
print (myAesonValue :: Either String Aeson.Value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment