Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Update Madness to master #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Update Madness to master #11

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 31, 2015

Now ogdl-swift is using an really old version of Madness. Meanwhile Madness made Parser generic for all CollectionType's instead of only String and this is a big change in the api, so i thought this PR would make it a bit easier to move to the next official release 馃槃.

@@ -105,12 +105,12 @@ private func foldr<G: GeneratorType, Result>(inout generator: G, initial: Result
return generator.next().map { combine($0, foldr(&generator, initial, combine)) } ?? initial
}

private func | <T, U> (left: Parser<T>.Function, right: String -> U) -> Parser<Either<T, U>>.Function {
return left | { (right($0), $0) }
private func | <C: CollectionType, T, U where C.Generator.Element: Equatable>(left: Parser<C, T>.Function, right: () -> U) -> Parser<C, Either<T, U>>.Function {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it would be better if the type of right was: (C, C.Index) -> U but then compiling takes endlessly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let鈥檚 not sweat it.

@robrix
Copy link
Contributor

robrix commented Sep 5, 2015

馃憤 this is very helpful, thank you.

(line(n)|? ++ followingLine(n)*) --> { ($0 ?? []) + flatMap($1, id) }
private let followingLine: Int -> Parser<String, [Node]>.Function = { n in (ignore(comment | br)+ ++ line(n)) }
private let lines: Int -> Parser<String, [Node]>.Function = { n in
{ ($0 ?? []) + flatMap($1, id) } <^> (line(n)|? ++ followingLine(n)*)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: tabs, not spaces.

@robrix
Copy link
Contributor

robrix commented Sep 5, 2015

Spaces/tabs thing is the only thing I noticed. Thanks for the PR! 馃憤

@ghost
Copy link
Author

ghost commented Nov 16, 2015

Finally fixed indentation. Sorry that it took so long 馃槥. Now working on converting it to swift 2, but i will do that in another PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant