Re: [swift-users] Why no new Development Snapshots since Aug 3?

2017-08-15 Thread Mishal Shah via swift-users
Hi Jens, 

Can you please try again? It should be fixed now. 

Thanks,
Mishal Shah

> On Aug 15, 2017, at 9:36 PM, Jens Persson  > wrote:
> 
> Follow up question:
> The current snapshot link 
> https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2017-08-15-a/swift-DEVELOPMENT-SNAPSHOT-2017-08-15-a-osx.pkg
>  
> 
> doesn't work:
> Forbidden
> You don't have permission to access 
> /builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2017-08-15-a/swift-DEVELOPMENT-SNAPSHOT-2017-08-15-a-osx.pkg
>  on this server.
> 
> (I could download 2017-08-14 yesterday though.)
> /Jens
> 
> On Fri, Aug 11, 2017 at 9:55 PM, Jens Persson via swift-users 
> mailto:swift-users@swift.org>> wrote:
> Ok, thanks!
> /Jens
> 
> On Fri, Aug 11, 2017 at 5:39 AM, Mishal Shah  > wrote:
> Hi Jens, 
> 
> We are working on resolving LLDB build and test failures, once these failures 
>  have been resolved we will be releasing new toolchains.
> 
> https://ci.swift.org/job/oss-lldb-incremental-osx/ 
> 
> https://ci.swift.org/job/oss-lldb-incremental-linux-ubuntu-16_04/ 
> 
> https://ci.swift.org/job/oss-lldb-incremental-linux-ubuntu-16_10/ 
> 
> 
> Thanks,
> Mishal Shah
> 
>> On Aug 10, 2017, at 6:42 PM, Jens Persson via swift-users 
>> mailto:swift-users@swift.org>> wrote:
>> 
>> The most recent Development Snapshot is 2017-08-03, but it used to be a new 
>> one almost daily. What happened?
>> /Jens
>> ___
>> swift-users mailing list
>> swift-users@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-users 
>> 
> 
> 
> 
> ___
> swift-users mailing list
> swift-users@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-users 
> 
> 
> 

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Why no new Development Snapshots since Aug 3?

2017-08-15 Thread Jens Persson via swift-users
Follow up question:
The current snapshot link
https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2017-08-15-a/swift-DEVELOPMENT-SNAPSHOT-2017-08-15-a-osx.pkg
doesn't work:
Forbidden
You don't have permission to access
/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2017-08-15-a/swift-DEVELOPMENT-SNAPSHOT-2017-08-15-a-osx.pkg
on this server.

(I could download 2017-08-14 yesterday though.)
/Jens

On Fri, Aug 11, 2017 at 9:55 PM, Jens Persson via swift-users <
swift-users@swift.org> wrote:

> Ok, thanks!
> /Jens
>
> On Fri, Aug 11, 2017 at 5:39 AM, Mishal Shah 
> wrote:
>
>> Hi Jens,
>>
>> We are working on resolving LLDB build and test failures, once these
>> failures  have been resolved we will be releasing new toolchains.
>>
>> https://ci.swift.org/job/oss-lldb-incremental-osx/
>> https://ci.swift.org/job/oss-lldb-incremental-linux-ubuntu-16_04/
>> https://ci.swift.org/job/oss-lldb-incremental-linux-ubuntu-16_10/
>>
>> Thanks,
>> Mishal Shah
>>
>> On Aug 10, 2017, at 6:42 PM, Jens Persson via swift-users <
>> swift-users@swift.org> wrote:
>>
>> The most recent Development Snapshot is 2017-08-03, but it used to be a
>> new one almost daily. What happened?
>> /Jens
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
>>
>>
>>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] custom binding pattern matches

2017-08-15 Thread David Young via swift-users
Sometimes I wish for custom *binding* patterns in Swift.  Is something
like this already in the works?  Anyone else wishing for this?

I have attached some code where I fake it, but these examples
show what I'm really after:

/* Match complex numbers, let expressions with type qualification: */

for elt in [1.0 + î, 2.0 + 3.0 * î, 4.0 + 5.0 * î, 6.0 * î] {
switch elt {
case î * (let d: Double):
print("matched î * \(d)")
case 1 + î * (let a: Double):
print("matched 1 + î * \(a)")
case (let b: Double) + î * (let c: Double):
print("matched \(b) + î * \(c)")
default:
print("no match")
}
}

/* Match complex numbers, let expressions with types inferred: */

for elt in [1.0 + î, 2.0 + 3.0 * î, 4.0 + 5.0 * î, 6.0 * î] {
switch elt {
case î * (let d):
print("matched î * \(d)")
case 1 + î * (let a):
print("matched 1 + î * \(a)")
case (let b) + î * (let c):
print("matched \(b) + î * \(c)")
default:
print("no match")
}
}

/* Match strings, assigning substrings to numeric types a la scanf(3): */

if case "\(let a: Double) + \(let b: Double) î" = "1 + 2 î"  {
print("matched \(a) + \(b) î")
}

/* Approximately match strings; `fuzz` is an "edit distance" between
 * the pattern and the match.
 */ 

if case ApproximateMatch("\(let a: Double) + \(let b: Double) î", let fuzz) = 
"1 + 2 * î", fuzz < 5 {
print("matched \(a) + \(b) î with fuzz \(d)")
}

/* Simplify an algebraic expression: n1 / d + n2 / d -> (n1 + n2) / d.
 *
 * Original source:
 */

if case .sum(.quotient(let ln, let ld),
 .quotient(let rn, let rd)) = expr, ld == rd {
return evaluate(.quotient(.sum(ln, rn), ld), env)
}

/* => with operator overloading (no custom binding patterns) becomes: */

if case .sum(.quotient(let ln, let ld),
 .quotient(let rn, let rd)) = expr, ld == rd {
return evaluate((ln + rn) / ld, env)
}

/* => with custom binding patterns and operator overloading becomes: */

if case (let ln: Expr) / (let ld: Expr) +
(let rn: Expr) / (let rd: Expr) = expr, ld == rd {
return evaluate((ln + rn) / ld, env)
}

/* => with type inference becomes: */

if case (let ln) / (let ld) + (let rn) / (let rd) = expr, ld == rd {
return evaluate((ln + rn) / ld, env)
}

Dave

-- 
David Young
dyo...@pobox.comUrbana, IL(217) 721-9981
enum Binds {
case constant(T)
case bind((T) -> Bool)
case matchless
}

extension Binds : CustomStringConvertible {
var description: String {
switch self {
case .bind(_):
return ".bind(_)"
case .constant(let x):
return ".constant(\(x))"
case .matchless:
return ".matchless"
}
}
}

func ~=(pattern: Binds, value: T) -> Bool {
switch pattern {
case .bind(let bind):
return bind(value)
case .constant(value):
return true
default:
return false
}
}
/* a + b î */
struct Complex {
let a: A
let b: B
init(_ a: A, _ b: B) {
self.a = a
self.b = b
}
}

let î = Complex(0, 1)

func ~=(pattern: Complex, Binds>, value: Complex) -> Bool {
return pattern.a ~= value.a && pattern.b ~= value.b
}

func +(l: Complex, Binds>,
   r: Complex, Binds>)
-> Complex, Binds> {
return Complex(l.a + r.a, r.a + r.b)
}

func *(l: Complex, Binds>,
   r: Complex, Binds>)
-> Complex, Binds> {
return Complex(l.a * r.a - l.b * r.b, l.a * r.b + l.b * r.a)
}

func +(l: Binds, r: Complex, Binds>)
-> Complex, Binds> {
return Complex(l + r.a, r.b)
}

func +(l: Double, r: Complex, Binds>)
-> Complex, Binds> {
return Complex(l + r.a, r.b)
}

func *(l: Double, r: Complex)
-> Complex {
return Complex(l * r.a, l * r.b)
}

func +(l: Double, r: Complex)
-> Complex {
return Complex(l + r.a, r.b)
}

func +(l: Float, r: Complex)
-> Complex {
return Complex(Double(l) + r.a, r.b)
}

func *(l: Complex, r: Binds)
-> Complex, Binds> {
return Complex(l.a * r, l.b * r)
}

func *(l: Binds, r: Binds) -> Binds {
switch (l, r) {
case (.constant(let x), .constant(let y)):
return .constant(x * y)
case (.constant(0), _), (_, .constant(0)):
return .constant(0)
case (.constant(1), _):
return r
case (_, .constant(1)):
return l
default:
return .matchless
}
}

func -(l: Binds, r: Binds) -> Binds {
switch (l, r) {
case (.constant(let x), .constant(let y)):
return .constant(x - y)
case (.constant(0), .bind(let f)):