From b5a1e5e2dd72532165763c1dc9d492bcbadeed9a Mon Sep 17 00:00:00 2001 From: benjmhart Date: Mon, 18 May 2020 16:43:36 -0400 Subject: [PATCH] modified haskell tutorial to purescript syntax --- TUTORIAL.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/TUTORIAL.md b/TUTORIAL.md index 157cf24..cc23b50 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -286,21 +286,25 @@ is either a JSON boolean or the JSON ``null``. To validate a JSON value using Medea from Haskell: -```Haskell -import Control.Monad.Trans.Except (runExcept, runExceptT) -import Data.Aeson (Value) +```Purescript +import Prelude +import Effect (Effect) +import Effect.Log (log) +import Control.Monad.Except.Trans (runExceptT) +import Control.Monad.Except (runExcept) +import Data.Argonaut (Json) import Data.Medea.Loader (loadSchemaFromFile) import Data.Medea (validate) -main :: IO () +main :: Effect Unit main = do -- Compile a Medea schema graph from its file representation result <- runExceptT . loadSchemaFromFile $ "./my-schema.medea" case result of - Left e -> print e + Left e -> log e Right scm -> do -- Validate against the schema graph we just compiled - validation <- runExcept $ validate scm (myJson :: Value) + validation <- runExcept $ validate scm (myJson :: Json) case validation of Left e -> print e Right _ -> putStrLn "JSON is valid against schema"