Skip to content

Instantly share code, notes, and snippets.

@dgendill
Created March 26, 2017 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgendill/548c083555c9da4fca8fd23a5071d42a to your computer and use it in GitHub Desktop.
Save dgendill/548c083555c9da4fca8fd23a5071d42a to your computer and use it in GitHub Desktop.
Getting truely random numbers from RANDOM.org in PureScript
module Main where
-- bower install
-- "purescript-prelude": "^2.5.0"
-- "purescript-console": "^2.0.0"
-- "purescript-affjax": "^3.0.2"
import Prelude
import Control.Monad.Aff (launchAff)
import Control.Monad.Aff.Console (log)
import Data.Either (Either(..))
import Data.HTTP.Method (Method(..))
import Data.Maybe (Maybe(..))
import Network.HTTP.Affjax (affjax, defaultRequest)
main = launchAff $ do
res <- affjax $ defaultRequest {
url = "https://api.random.org/json-rpc/1/invoke",
method = Left POST,
content = Just """
{
"jsonrpc": "2.0",
"method": "generateIntegers",
"params": {
"apiKey":"your-api-key-here",
"n":20,
"min":1,
"max":20
},
"id": 42
}
"""
}
log res.response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment