Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save natefaubion/b18885c52014102de7624340c6cd6f6d to your computer and use it in GitHub Desktop.
Save natefaubion/b18885c52014102de7624340c6cd6f6d to your computer and use it in GitHub Desktop.
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Class
import Control.Monad.Aff (launchAff, Aff, makeAff, attempt)
import Control.Monad.Aff.Console (CONSOLE, log)
import Control.Monad.Eff.Exception (Error, try)
import Control.Monad.Except.Trans (ExceptT(..), runExceptT)
import Network.HTTP.Affjax as Ajax
import Data.Either (Either(..), either)
api1 = map _.response $ ExceptT $ attempt $ Ajax.get "/api1"
api2 x = map _.response $ ExceptT $ attempt $ Ajax.get ("/api" <> x)
main = launchAff $ map (either log log) $ runExceptT (api1 >>= api2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment