1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

Merge branch 'master' into diff-cofree-values

This commit is contained in:
joshvera 2015-10-14 16:49:28 -04:00
commit 46010e3096
3 changed files with 203 additions and 241 deletions

View File

@ -16,17 +16,6 @@ public enum Patch<A>: CustomDebugStringConvertible, CustomDocConvertible {
}
/// The cost of a patch to the diff.
public var cost: Int {
switch self {
case .Replace:
return 2
default:
return 1
}
}
public var inverse: Patch {
switch self {
case let .Replace(a, b):

View File

@ -8,7 +8,7 @@ public func SES<Term, A>(a: [Term], _ b: [Term], recur: (Term, Term) -> Free<A,
if b.isEmpty { return a.map { Diff.Pure(Patch.Delete($0)) } }
func cost(diff: Diff) -> Int {
return diff.map { $0.cost }.iterate { syntax in
return diff.map(const(1)).iterate { syntax in
switch syntax {
case .Leaf:
return 0
@ -75,4 +75,5 @@ public func SES<Term, A>(a: [Term], _ b: [Term], recur: (Term, Term) -> Free<A,
import Memo
import Prelude
import Stream

View File

@ -1,68 +1,13 @@
[
[{
"source": "Algorithm",
"categories": [
]
},
[
[{
"source": "Recursive",
"categories": [
]
},
[
]
],
[{
"source": "ByKey",
"categories": [
]
},
[
]
], {
"insert": [{
"source": "ByIndex",
"categories": [
]
},
[
]
]
}, {
"source": "mark",
"categories": [
]
},
[{
"source": "map(_:)",
"categories": [
]
},
[
]
]
]
], {
"insert": [{
"source": "FreeAlgorithm",
[{
"delete": [{
"source": "Algorithm",
"categories": [
]
},
[
[{
"source": "Pure",
"source": "Recursive",
"categories": [
]
@ -72,17 +17,7 @@
]
],
[{
"source": "Roll",
"categories": [
]
},
[
]
],
[{
"source": "analysis(ifPure:ifRoll:)",
"source": "ByKey",
"categories": [
]
@ -104,31 +39,6 @@
},
[
]
], {
"source": "mark",
"categories": [
]
},
[{
"source": "flatMap(_:)",
"categories": [
]
},
[
]
],
[{
"source": "evaluate(_:recur:)",
"categories": [
]
},
[
]
]
]
@ -142,14 +52,49 @@
]
},
"after": [{
"source": "FreeAlgorithm",
"source": "Algorithm",
"categories": [
]
},
[
[{
"source": "evaluate(_:)",
"source": "Recursive",
"categories": [
]
},
[
]
],
[{
"source": "ByKey",
"categories": [
]
},
[
]
],
[{
"source": "ByIndex",
"categories": [
]
},
[
]
], {
"source": "mark",
"categories": [
]
},
[{
"source": "map(_:)",
"categories": [
]
@ -190,107 +135,125 @@
]
]
]
}, {
"delete": [{
"source": "FreeAlgorithm",
"categories": [
]
},
[
[{
"source": "Pure",
"categories": [
]
},
[
]
],
[{
"source": "Roll",
"categories": [
]
},
[
]
],
[{
"source": "analysis(ifPure:ifRoll:)",
"categories": [
]
},
[
]
], {
"source": "mark",
"categories": [
]
},
[{
"source": "map(_:)",
"categories": [
]
},
[
]
], {
"source": "mark",
"categories": [
]
},
[{
"source": "flatMap(_:)",
"categories": [
]
},
[
]
],
[{
"source": "evaluate(_:)",
"categories": [
]
},
[
]
]
]
]
}, {
"delete": [{
"source": "FreeAlgorithm",
"categories": [
]
},
[
[{
"source": "evaluate()",
"categories": [
]
},
[
]
]
]
]
},
[{
"source": "FreeAlgorithm",
"categories": [
]
},
[
[{
"source": "Pure",
"categories": [
]
},
[
]
],
[{
"source": "Roll",
"categories": [
]
},
[
]
],
[{
"source": "analysis(ifPure:ifRoll:)",
"categories": [
]
},
[
]
], {
"source": "mark",
"categories": [
]
},
[{
"source": "map(_:)",
"categories": [
]
},
[
]
], {
"source": "mark",
"categories": [
]
},
[{
"source": "flatMap(_:)",
"categories": [
]
},
[
]
],
[{
"replace": {
"before": {
"source": "evaluate(_:)",
"categories": [
]
},
"after": {
"source": "evaluate(_:recur:)",
"categories": [
]
}
}
},
[
]
]
]
],
[{
"source": "FreeAlgorithm",
"categories": [
]
},
[
[{
"replace": {
"before": {
"source": "evaluate()",
"categories": [
]
},
"after": {
"source": "evaluate(_:)",
"categories": [
]
}
}
},
[
]
]
]
],
[{
"source": "FreeConvertible",
"categories": [
@ -338,36 +301,6 @@
]
}
]
],
[{
"source": "FreeAlgorithm",
"categories": [
]
},
[
[{
"source": "init(_:_:)",
"categories": [
]
},
[
]
], {
"insert": [{
"source": "evaluate(_:)",
"categories": [
]
},
[
]
]
}
]
], {
"insert": [{
"source": "FreeAlgorithm",
@ -377,7 +310,17 @@
},
[
[{
"source": "evaluate()",
"source": "init(_:_:)",
"categories": [
]
},
[
]
],
[{
"source": "evaluate(_:)",
"categories": [
]
@ -388,5 +331,34 @@
]
]
]
}
},
[{
"source": "FreeAlgorithm",
"categories": [
]
},
[
[{
"replace": {
"before": {
"source": "init(_:_:)",
"categories": [
]
},
"after": {
"source": "evaluate()",
"categories": [
]
}
}
},
[
]
]
]
]
]