Scala: Implementing a subtype of Numeric[T]

后端 未结 2 1105
野性不改
野性不改 2021-02-03 14:32

How does one go about implementing a subtype of Numeric[T]? I have been looking for at guide on this but haven\'t found any. Example of subtypes could be Rational or Complex?

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-03 14:53

    I added Real to Scalaz, with instances Real[Double] and Real[Dual].

    I found it convenient to make fromDouble implicit

提交回复
热议问题