-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make fix
polymorphic in two type variables
#30
make fix
polymorphic in two type variables
#30
Conversation
enable version `fixt`
return { x in f(fix(f))(x) } | ||
} | ||
|
||
/// The fixpoint (or Y) combinator computes the least fixed point of an equation. That is, the first | ||
/// point at which further application of x to a function is the same x. | ||
/// fixt is the exception enabled version of fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an extra line of
///
above this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And put fixt
in a pair of backticks?
comment line /// added above `fixt` definition.
/// The fixpoint (or Y) combinator computes the least fixed point of an equation. That is, the first | ||
/// point at which further application of x to a function is the same x. | ||
/// fixt is the exception-enabled version of fix. | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, other way around:
/// The fixpoint (or Y) combinator computes the least fixed point of an equation. That is, the first
/// point at which further application of x to a function is the same x.
///
/// `fixt` is the exception-enabled version of fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to know markdown is partially supported :)
On Sun, Sep 6, 2015 at 9:18 PM Robert Widmann notifications@github.com
wrote:
In Swiftx/Combinators.swift
#30 (comment):return { x in f(fix(f))(x) }
}
+/// The fixpoint (or Y) combinator computes the least fixed point of an equation. That is, the first
+/// point at which further application of x to a function is the same x.
+/// fixt is the exception-enabled version of fix.
+///Whoops, other way around:
/// The fixpoint (or Y) combinator computes the least fixed point of an equation. That is, the first
/// point at which further application of x to a function is the same x.
//////
fixt
is the exception-enabled version of fix.—
Reply to this email directly or view it on GitHub
https://github.com/typelift/Swiftx/pull/30/files#r38825650.
Why are we not using |
(For my own memory, tying this to #29). |
@pthariensflame : The swift-2.0 compiler complains with: |
did I break the Travis CI build? |
The build is broken anyways because Travis is using 1.2 while |
Your error is because the function is missing a |
This definition compiles public func fixt<A, B>(f : (A throws -> B) throws -> (A throws -> B)) rethrows -> A throws -> B {
return { x in try f(fixt(f))(x) }
} |
Thanks for this. Looks better to me. On Sun, Sep 6, 2015 at 9:30 PM Robert Widmann notifications@github.com
|
fixt now uses rethrows correctly
@pthariensflame @CodaFi thanks for the fix of I'd love to have a clear idea about the difference in behaviour of the Please do add any comments here that will help clarify this difference. |
From the type signature you presented, it says the fixpoint of a throwing function always throws itself. While we're making that call, we may as well assume the body after the recur can throw too, in which case we shouldnt eat the error. |
@DanielAsher It was an honor and a pleasure to be the outlet for your first github pull request. Thank you so much for the changes you've made here ✨ ⛵ |
make `fix` polymorphic in two type variables
and add an exception enabled version
fixt