-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLibrary.scala
46 lines (40 loc) · 991 Bytes
/
Library.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package ilc
package feature
package abelianGroups
object Library extends base.Library {
trait AbelianGroup[T] {
def binOp: (=>T) => (=>T) => T
def inv: (=>T) => T
def neutral: T
def isEqualGroup(that: AbelianGroup[T]): Boolean
override def equals(that: Any): Boolean = that match {
case that: AbelianGroup[T] =>
this.isEqualGroup(that)
case _ =>
false
}
}
object IndexedGroup {
def curried[T]:
(=> Int) =>
(=> ((=>T) => (=>T) => T)) => (=>((=>T) => T)) => (=>T) =>
AbelianGroup[T] =
id => binOp => inv => neutral =>
IndexedGroup(id, binOp, inv, neutral)
}
case class IndexedGroup[T](
id: Int,
binOp: (=>T) => (=>T) => T,
inv: (=>T) => T,
neutral: T
)
extends AbelianGroup[T]
{
def isEqualGroup(that: AbelianGroup[T]): Boolean = that match {
case IndexedGroup(thatId, _, _, _) =>
this.id == thatId
case _ =>
false
}
}
}