Created
April 24, 2014 19:05
-
-
Save relrod/11265789 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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