Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type FetchPage = String => String
- type FindImages = String => List[String]
- object WillFetchPage extends FetchPage {
- def apply(url:String):String = /* get content of the url */
- }
- class WillFindImages(fetchPage: FetchPage) extends FindImages {
- def apply(url:String):List[String] = {
- val html = fetchPage(url)
- // get image srcs from the <img> tags
- }
- }
- val findImages = new WillFindImages(WillFetchPage)
- val testFindImages = new WillFindImages(_ => "html-have-3-images")
- val images = testFindImages("any-url")
- // assertion
- sealed trait KiloGram
- def KiloGram[A](a: A): A @@ KiloGram = Tag[A, KiloGram](a)
- val mass = KiloGram(20.0)
- 2 * mass
- object FetchPage extends ((String => Try[String]) @@ FetchType)
- Error:(18, 51) class type required but String => scala.util.Try[String] with
- scalaz.Tagged[object_as_func.FetchType] found
- object FetchPage extends ((String => Try[String]) @@ FetchType) {
- ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement