Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified haskell tutorial to purescript syntax #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
16 changes: 10 additions & 6 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,25 @@ is either a JSON boolean or the JSON ``null``.

To validate a JSON value using Medea from Haskell:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean 'PureScript' right?


```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"
Expand Down