Skip to content

Commit

Permalink
uncomment Nat examples
Browse files Browse the repository at this point in the history
  • Loading branch information
harrah committed Jun 22, 2010
1 parent 168cadc commit 49a394d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
25 changes: 20 additions & 5 deletions Comparison.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
sealed trait Comparison {
type gt = Match[False, False, True, Bool]
type ge = Match[False, True, True, Bool]
type eq = Match[False, True, False, Bool]
type le = Match[True, True, False, Bool]
type lt = Match[True, False, False, Bool]
type gt <: Bool
type ge <: Bool
type eq <: Bool
type le <: Bool
type lt <: Bool
type Match[IfLT <: Up, IfEQ <: Up, IfGT <: Up, Up] <: Up
}
sealed trait GT extends Comparison {
type Match[IfLT <: Up, IfEQ <: Up, IfGT <: Up, Up] = IfGT
type eq = False
type gt = True
type lt = False
type le = False
type ge = True
}
sealed trait LT extends Comparison {
type Match[IfLT <: Up, IfEQ <: Up, IfGT <: Up, Up] = IfLT
type eq = False
type gt = False
type lt = True
type le = True
type ge = False
}
sealed trait EQ extends Comparison {
type Match[IfLT <: Up, IfEQ <: Up, IfGT <: Up, Up] = IfEQ
type eq = True
type gt = False
type lt = False
type le = True
type ge = True
}
object Comparison {
def show[C <: Comparison](implicit rep: ComparisonRep[C]): String = rep.value
Expand Down
2 changes: 1 addition & 1 deletion Nat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ sealed trait Nat0 extends Nat {
type Compare[N <: Nat] = N#Match[ConstLT, EQ, Comparison]
}
sealed trait Succ[N <: Nat] extends Nat {
type FoldR[Init <: Type, Type, F <: Fold[Nat, Type]] = F#Apply[Succ[N], N#FoldR[Init, Type, F]]//N#FoldR[F#Apply[Succ[N],Init], Type, F]
type FoldR[Init <: Type, Type, F <: Fold[Nat, Type]] = F#Apply[Succ[N], N#FoldR[Init, Type, F]]
type FoldL[Init <: Type, Type, F <: Fold[Nat, Type]] = N#FoldL[F#Apply[Succ[N],Init], Type, F]
type Match[NonZero[N <: Nat] <: Up, IfZero <: Up, Up] = NonZero[N]
type Compare[O <: Nat] = O#Match[N#Compare, GT, Comparison]
Expand Down
6 changes: 3 additions & 3 deletions NatTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Bool._
object NatTest
{
val true = toBoolean[ Sq[_9] === ( _1 + (_8 x _10) )]
//val true = toBoolean[ Eq[ Sq[Sq[_9]], Sq[Add[_1,Mult[_8,_10]]] ] ]
//val true = toBoolean[ Eq[ Mod[ Exp[_9,_4], _6], _3] ]
//val true = toInt[ Mod[ Sq[_9], _6] ] == 81 % 6
val true = toBoolean[ Sq[Sq[_9]] === Sq[_1 + (_8 x _10) ] ]
val true = toBoolean[ ( (_9 ^ _4) % _6) === _3 ]
val true = toInt[ ( Sq[_9] % _6 ) ] == 81 % 6
def run() {}
}

0 comments on commit 49a394d

Please sign in to comment.