Skip to content

Instantly share code, notes, and snippets.

@alexy
Forked from betehess/ammonite-shapeless
Last active August 29, 2015 14:22
Show Gist options
  • Save alexy/f7069876e0155e0ec997 to your computer and use it in GitHub Desktop.
Save alexy/f7069876e0155e0ec997 to your computer and use it in GitHub Desktop.
> runMain ammonite.repl.Repl
[info] Running ammonite.repl.Repl
Loading Ammonite Repl...
@ load.ivy("com.chuusai" %% "shapeless" % "2.1.0")
@ import shapeless._
import shapeless._
@ 1 :: "lol" :: List(1, 2, 3) :: HNil
res2: Int :: String :: List[Int] :: HNil = ::(
1,
::("lol", ::(List(1, 2, 3), HNil))
)
@ import ammonite.pprint._
import ammonite.pprint._
@ implicit val hnilPPrinter: PPrinter[HNil] = PPrinter[HNil] { (hnil, cfg) => Iterator("HNil") }
hnilPPrinter: PPrinter[HNil] = ammonite.pprint.PPrinter$$anon$1@3e8db096
@ implicit def hlistPPrinter[T <: HList, H](implicit
tailPPrinter: PPrinter[T],
headPPrint: PPrint[H]
): PPrinter[H :: T] = PPrinter { case (h :: t, cfg) =>
headPPrint.render(h) ++ Iterator(" :: ") ++ tailPPrinter.render(t, cfg)
}
defined function hlistPPrinter
@ 1 :: "lol" :: List(1, 2, 3) :: HNil
res6: Int :: String :: List[Int] :: HNil = 1 :: "lol" :: List(1, 2, 3) :: HNil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment