Advertisement
Guest User

Untitled

a guest
Sep 21st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. type FetchPage = String => String
  2. type FindImages = String => List[String]
  3.  
  4. object WillFetchPage extends FetchPage {
  5. def apply(url:String):String = /* get content of the url */
  6. }
  7.  
  8. class WillFindImages(fetchPage: FetchPage) extends FindImages {
  9. def apply(url:String):List[String] = {
  10. val html = fetchPage(url)
  11. // get image srcs from the <img> tags
  12. }
  13. }
  14.  
  15. val findImages = new WillFindImages(WillFetchPage)
  16.  
  17. val testFindImages = new WillFindImages(_ => "html-have-3-images")
  18. val images = testFindImages("any-url")
  19. // assertion
  20.  
  21. sealed trait KiloGram
  22.  
  23. def KiloGram[A](a: A): A @@ KiloGram = Tag[A, KiloGram](a)
  24.  
  25. val mass = KiloGram(20.0)
  26.  
  27. 2 * mass
  28.  
  29. object FetchPage extends ((String => Try[String]) @@ FetchType)
  30.  
  31. Error:(18, 51) class type required but String => scala.util.Try[String] with
  32. scalaz.Tagged[object_as_func.FetchType] found
  33. object FetchPage extends ((String => Try[String]) @@ FetchType) {
  34. ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement