Skip to content

Instantly share code, notes, and snippets.

@DamianReeves
DamianReeves / Actor.scala
Created November 13, 2024 17:01
Actors with Kyo
package kyo
import kyo.Actor.Service
import kyo.kernel.Boundary
import kyo.kernel.Reducible
/** An actor prototype not considering aspects like identity and supervision. I think we could initially go with a minimal approach similar
* to this one providing local isolated actors.
*
* Instead of leaving the decision to handle the result of an actor message to the caller, this prototype separates actors into two kinds:
@DamianReeves
DamianReeves / morphir-ir.json
Created May 21, 2024 22:38
Morphir IR - Parent
{"formatVersion":3,"distribution":["Library",[["parent"],["one"]],[],{"modules":[[[["module","1"]],{"access":"Public","value":{"types":[[["type","1"],{"access":"Public","value":{"doc":"","value":["TypeAliasDefinition",[],["Record",{},[{"name":["foo"],"tpe":["Reference",{},[[["morphir"],["s","d","k"]],[["basics"]],["int"]],[]]},{"name":["bar"],"tpe":["Reference",{},[[["morphir"],["s","d","k"]],[["basics"]],["bool"]],[]]}]]]}}]],"values":[],"doc":null}}]]}]}
@DamianReeves
DamianReeves / BreadthFirst.scala
Created May 16, 2023 19:57
ZIO Breadth first
sealed trait State
case object PullOuter extends State
case class PullInner(
stream: ZIO[R1, Option[Nothing], Chunk[Option[B]]],
chunk: Chunk[Option[B]],
index: Int,
finalizer: Exit[Any, Any] => UIO[Any]
) extends State
@DamianReeves
DamianReeves / RestrictionAnalyzer.fs
Created May 12, 2023 15:45
F# Analyzer to Restrict language
module RestrictionAnalyzer
open FSharp.Analyzers.SDK
open FSharp.Compiler.Text
open FSharp.Compiler.Syntax
let hasTypeInNamespace (target:SynModuleOrNamespace): Message option =
match target with
| SynModuleOrNamespace(kind = SynModuleOrNamespaceKind.DeclaredNamespace; decls = decls) ->
let hasTypes =
@DamianReeves
DamianReeves / Idea01.scala
Last active January 4, 2023 19:38
Morphir Macro ideas
trait PersonModule {
trait Person { def name: String; def age: Int }
}
trait ModuleDef[T] {
val value: T
}
// val myModule: ModuleDef[PersonModule] =
❯ scala-cli package . --native-image --graalvm-jvm-id system

Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Downloading: Component native-image: Native Image from github.com
I/O error occurred: Remote host terminated the handshake
Error: os.SubprocessException: CommandResult 2
@DamianReeves
DamianReeves / GitOps.scala
Last active July 20, 2022 13:21
Generate morphir-ir
import upickle.default._
object GitOps {
lazy val gitExe = if (scala.util.Properties.isWin) "git.exe" else "git"
implicit val GivenOsPathReader: ReadWriter[os.Path] =
readwriter[String].bimap(_.toString, os.Path(_))
final case class GitCloneOptions(
repository: String,
@DamianReeves
DamianReeves / ValueCase.scala
Created April 4, 2022 22:24
Scala Type Lambda Trick
import zio.prelude._
sealed trait ValueCase[+TA,+VA,+Self] { self => }
object ValueCase {
// Would have cases defined
type Curry[A[+_, +_, +_], T, U] = { type Result[+V] = A[T, U, V] }
implicit def ValueCaseForEach[TA, VA]: ForEach[Curry[ValueCase, TA, VA]#Result]] = ???
}
@DamianReeves
DamianReeves / Field.scala
Created July 31, 2021 01:10
Field Properties
package datadictionary
import datadictionary.Field.Modifier
type AnyField = Field[?, Nothing, Nothing]
type AnyFieldHavingKeyOf[K <: Field.FieldKey] = Field[K, Nothing, Nothing]
final case class Field[Key <: Field.FieldKey, +A, +Attribs](key: Key) extends Serializable:
def asConstant(using Attribs <:< Modifier.Assignable) = ???
override def toString: String = key
@DamianReeves
DamianReeves / Error.md
Last active August 14, 2020 11:33
Mill Build issue

Exception in thread "MillServerActionRunner" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at mill.define.Module$Internal.$anonfun$reflect$4(Module.scala:73) at scala.collection.ArrayOps$WithFilter.map(ArrayOps.scala:90) at mill.define.Module$Internal.reflect(Module.scala:64) at mill.define.Module$Internal.reflectAll(Module.scala:76)