Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
> 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