diff --git a/nescant/src/main/scala/com/htmlism/nescant/Sink.scala b/nescant/src/main/scala/com/htmlism/nescant/ByteSink.scala similarity index 64% rename from nescant/src/main/scala/com/htmlism/nescant/Sink.scala rename to nescant/src/main/scala/com/htmlism/nescant/ByteSink.scala index 61af4a9..f86a762 100644 --- a/nescant/src/main/scala/com/htmlism/nescant/Sink.scala +++ b/nescant/src/main/scala/com/htmlism/nescant/ByteSink.scala @@ -1,7 +1,7 @@ package com.htmlism.nescant -trait Sink[A] +trait ByteSink[A] -object Sink { +object ByteSink { // TODO int cannot be a source } diff --git a/nescant/src/main/scala/com/htmlism/nescant/ByteSource.scala b/nescant/src/main/scala/com/htmlism/nescant/ByteSource.scala new file mode 100644 index 0000000..783ae4b --- /dev/null +++ b/nescant/src/main/scala/com/htmlism/nescant/ByteSource.scala @@ -0,0 +1,8 @@ +package com.htmlism.nescant + +trait ByteSource[A] + +object ByteSource { + implicit val sourceForInt: ByteSource[Int] = + new ByteSource[Int] {} +} diff --git a/nescant/src/main/scala/com/htmlism/nescant/GlobalAddress.scala b/nescant/src/main/scala/com/htmlism/nescant/GlobalAddress.scala index 5c8c05c..6423782 100644 --- a/nescant/src/main/scala/com/htmlism/nescant/GlobalAddress.scala +++ b/nescant/src/main/scala/com/htmlism/nescant/GlobalAddress.scala @@ -1,11 +1,11 @@ package com.htmlism.nescant object GlobalAddress { - implicit val sourceForGlobalAddress: Source[GlobalAddress] = - new Source[GlobalAddress] {} + implicit val sourceForGlobalAddress: ByteSource[GlobalAddress] = + new ByteSource[GlobalAddress] {} - implicit val sinkForGlobalAddress: Sink[GlobalAddress] = - new Sink[GlobalAddress] {} + implicit val sinkForGlobalAddress: ByteSink[GlobalAddress] = + new ByteSink[GlobalAddress] {} } case class GlobalAddress(n: Int) diff --git a/nescant/src/main/scala/com/htmlism/nescant/ReadWriteLocation.scala b/nescant/src/main/scala/com/htmlism/nescant/ReadWriteLocation.scala index 4e1aee3..8c85e2c 100644 --- a/nescant/src/main/scala/com/htmlism/nescant/ReadWriteLocation.scala +++ b/nescant/src/main/scala/com/htmlism/nescant/ReadWriteLocation.scala @@ -8,11 +8,11 @@ package com.htmlism.nescant case class ReadWriteLocation[A](name: String, address: ZeroPageAddress) object ReadWriteLocation { - implicit def sourceForReadWriteLocation[A: Operand]: Source[ReadWriteLocation[A]] = - new Source[ReadWriteLocation[A]] {} + implicit def sourceForReadWriteLocation[A: Operand]: ByteSource[ReadWriteLocation[A]] = + new ByteSource[ReadWriteLocation[A]] {} - implicit def sinkForReadWriteLocation[A: Operand]: Sink[ReadWriteLocation[A]] = - new Sink[ReadWriteLocation[A]] {} + implicit def sinkForReadWriteLocation[A: Operand]: ByteSink[ReadWriteLocation[A]] = + new ByteSink[ReadWriteLocation[A]] {} implicit def operandForReadWriteLocation[A: Operand]: Operand[ReadWriteLocation[A]] = new Operand[ReadWriteLocation[A]] { diff --git a/nescant/src/main/scala/com/htmlism/nescant/Source.scala b/nescant/src/main/scala/com/htmlism/nescant/Source.scala deleted file mode 100644 index 2cf3ed5..0000000 --- a/nescant/src/main/scala/com/htmlism/nescant/Source.scala +++ /dev/null @@ -1,8 +0,0 @@ -package com.htmlism.nescant - -trait Source[A] - -object Source { - implicit val sourceForInt: Source[Int] = - new Source[Int] {} -} diff --git a/nescant/src/main/scala/com/htmlism/nescant/VolatileDevice.scala b/nescant/src/main/scala/com/htmlism/nescant/VolatileDevice.scala index 8822d0d..7c83d0c 100644 --- a/nescant/src/main/scala/com/htmlism/nescant/VolatileDevice.scala +++ b/nescant/src/main/scala/com/htmlism/nescant/VolatileDevice.scala @@ -12,8 +12,8 @@ package com.htmlism.nescant case class VolatileDevice[A](name: String, address: ZeroPageAddress) object VolatileDevice { - implicit def sourceForVolatileDevice[A: Operand]: Source[VolatileDevice[A]] = - new Source[VolatileDevice[A]] {} + implicit def sourceForVolatileDevice[A: Operand]: ByteSource[VolatileDevice[A]] = + new ByteSource[VolatileDevice[A]] {} implicit def operandForVolatileDevice[A: Operand]: Operand[VolatileDevice[A]] = new Operand[VolatileDevice[A]] { diff --git a/nescant/src/main/scala/com/htmlism/nescant/ZeroPageAddress.scala b/nescant/src/main/scala/com/htmlism/nescant/ZeroPageAddress.scala index 79b1f62..904abf7 100644 --- a/nescant/src/main/scala/com/htmlism/nescant/ZeroPageAddress.scala +++ b/nescant/src/main/scala/com/htmlism/nescant/ZeroPageAddress.scala @@ -1,11 +1,11 @@ package com.htmlism.nescant object ZeroPageAddress { - implicit val sourceForZeroPageAddress: Source[ZeroPageAddress] = - new Source[ZeroPageAddress] {} + implicit val sourceForZeroPageAddress: ByteSource[ZeroPageAddress] = + new ByteSource[ZeroPageAddress] {} - implicit val sinkForZeroPageAddress: Sink[ZeroPageAddress] = - new Sink[ZeroPageAddress] {} + implicit val sinkForZeroPageAddress: ByteSink[ZeroPageAddress] = + new ByteSink[ZeroPageAddress] {} } case class ZeroPageAddress(n: Int) diff --git a/nescant/src/main/scala/com/htmlism/nescant/dsl/package.scala b/nescant/src/main/scala/com/htmlism/nescant/dsl/package.scala index b61731e..64770e1 100644 --- a/nescant/src/main/scala/com/htmlism/nescant/dsl/package.scala +++ b/nescant/src/main/scala/com/htmlism/nescant/dsl/package.scala @@ -9,8 +9,8 @@ package object dsl { GlobalAddress(n) } - implicit class SinkOps[A: Sink](x: A) { - def write[B: Source](src: B): Unit = { + implicit class SinkOps[A: ByteSink](x: A) { + def write[B: ByteSource](src: B): Unit = { val _ = src } } diff --git a/nescant/src/test/scala/com/htmlism/nescant/dsl/ByteSinkSpec.scala b/nescant/src/test/scala/com/htmlism/nescant/dsl/ByteSinkSpec.scala new file mode 100644 index 0000000..1c28880 --- /dev/null +++ b/nescant/src/test/scala/com/htmlism/nescant/dsl/ByteSinkSpec.scala @@ -0,0 +1,21 @@ +package com.htmlism.nescant +package dsl + +import org.scalatest.flatspec._ +import org.scalatest.matchers._ + +class ByteSinkSpec extends AnyFlatSpec with should.Matchers { + "A zero page address" should "be a byte-wide sync" in { + 123.z.write(456) + } + + "A global address" should "be a byte-wide sync" in { + 123.g.write(456) + } + + "A read write location" should "be a byte-wide sync" in { + val sink = ReadWriteLocation[Int]("", 0.z) + + sink.write(456) + } +} diff --git a/nescant/src/test/scala/com/htmlism/nescant/dsl/ByteSourceSpec.scala b/nescant/src/test/scala/com/htmlism/nescant/dsl/ByteSourceSpec.scala new file mode 100644 index 0000000..86e7da4 --- /dev/null +++ b/nescant/src/test/scala/com/htmlism/nescant/dsl/ByteSourceSpec.scala @@ -0,0 +1,34 @@ +package com.htmlism.nescant +package dsl + +import org.scalatest.flatspec._ +import org.scalatest.matchers._ + +class ByteSourceSpec extends AnyFlatSpec with should.Matchers { + private val sink = + 123.z + + "A number" should "be a byte-wide source" in { + sink.write(456) + } + + "A zero page address" should "be a byte-wide source" in { + sink.write(456.z) + } + + "A global address" should "be a byte-wide source" in { + sink.write(456.g) + } + + "A volatile device" should "be a byte-wide source" in { + val src = VolatileDevice[Int]("", 0.z) + + sink.write(src) + } + + "A read write location" should "be a byte-wide source" in { + val src = ReadWriteLocation[Int]("", 0.z) + + sink.write(src) + } +} diff --git a/nescant/src/test/scala/com/htmlism/nescant/dsl/SinkSpec.scala b/nescant/src/test/scala/com/htmlism/nescant/dsl/SinkSpec.scala deleted file mode 100644 index 6bb1afc..0000000 --- a/nescant/src/test/scala/com/htmlism/nescant/dsl/SinkSpec.scala +++ /dev/null @@ -1,21 +0,0 @@ -package com.htmlism.nescant -package dsl - -import org.scalatest.flatspec._ -import org.scalatest.matchers._ - -class SinkSpec extends AnyFlatSpec with should.Matchers { - "A zero page address" should "be a sink" in { - 123.z.write(456) - } - - "A global address" should "be a sink" in { - 123.g.write(456) - } - - "A read write location" should "be a sink" in { - val sink = ReadWriteLocation[Int]("", 0.z) - - sink.write(456) - } -} diff --git a/nescant/src/test/scala/com/htmlism/nescant/dsl/SourceSpec.scala b/nescant/src/test/scala/com/htmlism/nescant/dsl/SourceSpec.scala deleted file mode 100644 index c5ca46c..0000000 --- a/nescant/src/test/scala/com/htmlism/nescant/dsl/SourceSpec.scala +++ /dev/null @@ -1,31 +0,0 @@ -package com.htmlism.nescant -package dsl - -import org.scalatest.flatspec._ -import org.scalatest.matchers._ - -class SourceSpec extends AnyFlatSpec with should.Matchers { - "A number" should "be a source" in { - 123.z.write(456) - } - - "A zero page address" should "be a source" in { - 123.z.write(456.z) - } - - "A global address" should "be a source" in { - 123.z.write(456.g) - } - - "A volatile device" should "be a source" in { - val src = VolatileDevice[Int]("", 0.z) - - 123.z.write(src) - } - - "A read write location" should "be a source" in { - val src = ReadWriteLocation[Int]("", 0.z) - - 123.z.write(src) - } -}