Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case class Node(name: String)
- case class Leaf(value: String, node: Node)
- case class InternalNode(children: List[Node], node: Node)
- object Node {
- implicit val show = new Show[Node] {
- override def show(node: Node): String = s"(${node.name.show})"
- }
- }
- object Leaf {
- implicit val show = Show[Node].contramap[Leaf](_.node)
- }
- object InternalNode {
- implicit val show = Show[Node].contramap[Leaf](_.node)
- }
- println(Leaf("1488", Node("mynode")).show)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement