You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I saw the talk from Greg Pfeil and found the park on mutual recursion really appealing.
I created a simple example of numeric and boolean operations that I would be happy to add to a documentation once I figure how to do traversals. It is a nice domain to document due to some obvious rewrites on boolean expressions.
I appreciate that we need a natural transformation to transform A (is higher-kinded Functor a thing?). But not sure if there is further infrastructure around this.
sealedtraitBoolAndCalcF[A[_],I]
// Using AtLeastTwoList as a more complex use casecaseclassAnd[A[_]](expressions: AtLeastTwoList[A[Boolean]]) extendsBoolAndCalcF[A, Boolean]
caseclassOr[A[_]](expressions: AtLeastTwoList[A[Boolean]]) extendsBoolAndCalcF[A, Boolean]
caseclassNot[A[_]](wrapped: A[Boolean]) extendsBoolAndCalcF[A, Boolean]
caseclassBoolVal[A[_]](value: Boolean) extendsBoolAndCalcF[A, Boolean]
// A bridge from calculation to booleanscaseclassCompare[A[_],I:Numeric, J:Numeric](left: A[I], op: CompOp, right: A[I]) extendsBoolAndCalcF[A, Boolean]
caseclassAdd[A[_], I:Numeric](left: A[I], right: A[I]) extendsBoolAndCalcF[A, I]
//To show it would not compose with the rest due to OptioncaseclassDivide[A[_], I:Numeric](left: A[I], right: A[I]) extendsBoolAndCalcF[A, Option[I]]
caseclassNum[A[_], I:Numeric](value: I) extendsBoolAndCalcF[A, I]
sealedtraitCompOpobjectCompOp {
caseobjectGTextendsCompOpcaseobjectLTextendsCompOpcaseobjectEQextendsCompOpcaseobjectNEextendsCompOpcaseobjectGEextendsCompOpcaseobjectLEextendsCompOp
}
//import cats.data.OneAnd//type AtLeastTwoList[A] = OneAnd[OneAnd[List,A],A]caseclassAtLeastTwoList[A](head: A, second:A, tail: List[A]) {
defmap[B](f: A=>B) =AtLeastTwoList(f(head), f(second), tail.map(f))
deffold[B](h: A=>B)(f: (B, A) =>B):B= tail.foldLeft[B](f(h(head), second))(f)
}
The text was updated successfully, but these errors were encountered:
So, there’s a PR (#28) with a bunch of mutual-recursion stuff on it, including working examples. However, a regression in scalac means it doesn’t compile anymore. I have an in-progress PR against scalac, but haven’t had a chance to finish it up.
Hi, I saw the talk from Greg Pfeil and found the park on mutual recursion really appealing.
I created a simple example of numeric and boolean operations that I would be happy to add to a documentation once I figure how to do traversals. It is a nice domain to document due to some obvious rewrites on boolean expressions.
I appreciate that we need a natural transformation to transform
A
(is higher-kinded Functor a thing?). But not sure if there is further infrastructure around this.The text was updated successfully, but these errors were encountered: