Skip to content

Instantly share code, notes, and snippets.

@relrod
Created April 24, 2014 19:05
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 relrod/11265789 to your computer and use it in GitHub Desktop.
Save relrod/11265789 to your computer and use it in GitHub Desktop.
package me.elrod.ph.examples
import scalaz._, Scalaz._, effect._, IO._
import me.elrod.ph.{Ph => http}
object DisplayIP extends SafeApp {
override def runc: IO[Unit] =
for {
ip <- http get "http://da.gd/ip?text&strip"
_ <- ip match {
case \/-(ip_) => putStrLn(ip_.body) // TODO: Lens (Monocle!)
case -\/(err) => putStrLn(err.toString)
}
} yield ()
}
/*
> project ph-examples
[info] Set current project to ph-examples (in build file:/home/ricky/devel/scala/ph/)
> run
[info] Running me.elrod.ph.examples.DisplayIP
98.27.131.138
[success] Total time: 1 s, completed Apr 24, 2014 3:02:21 PM
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment