Skip to content

Commit

Permalink
Reduce risk of conflict for precedence groups
Browse files Browse the repository at this point in the history
Turns out these need to be unique! Fun stuff. To reduce the risk of conflict
here lets go ahead and prefix our precedence group names with our package
name.

This sucks.
  • Loading branch information
gfontenot committed Sep 6, 2016
1 parent 7fab851 commit 5c07ea7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions Sources/Runes.swift
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
precedencegroup MonadicPrecedenceRight {
precedencegroup RunesMonadicPrecedenceRight {
associativity: right
lowerThan: LogicalDisjunctionPrecedence
higherThan: AssignmentPrecedence
}

precedencegroup MonadicPrecedenceLeft {
precedencegroup RunesMonadicPrecedenceLeft {
associativity: left
lowerThan: LogicalDisjunctionPrecedence
higherThan: AssignmentPrecedence
}

precedencegroup AlternativePrecedence {
precedencegroup RunesAlternativePrecedence {
associativity: left
higherThan: LogicalConjunctionPrecedence
lowerThan: ComparisonPrecedence
}

precedencegroup ApplicativePrecedence {
precedencegroup RunesApplicativePrecedence {
associativity: left
higherThan: AlternativePrecedence
higherThan: RunesAlternativePrecedence
lowerThan: NilCoalescingPrecedence
}

precedencegroup ApplicativeSequencePrecedence {
precedencegroup RunesApplicativeSequencePrecedence {
associativity: left
higherThan: ApplicativePrecedence
higherThan: RunesApplicativePrecedence
lowerThan: NilCoalescingPrecedence
}

Expand All @@ -34,55 +34,55 @@ map a function over a value with context
Expected function type: `(a -> b) -> f a -> f b`
Haskell `infixl 4`
*/
infix operator <^> : ApplicativePrecedence
infix operator <^> : RunesApplicativePrecedence

/**
apply a function with context to a value with context
Expected function type: `f (a -> b) -> f a -> f b`
Haskell `infixl 4`
*/
infix operator <*> : ApplicativePrecedence
infix operator <*> : RunesApplicativePrecedence

/**
sequence actions, discarding right (value of the second argument)
Expected function type: `f a -> f b -> f a`
Haskell `infixl 4`
*/
infix operator <* : ApplicativeSequencePrecedence
infix operator <* : RunesApplicativeSequencePrecedence

/**
sequence actions, discarding left (value of the first argument)
Expected function type: `f a -> f b -> f b`
Haskell `infixl 4`
*/
infix operator *> : ApplicativeSequencePrecedence
infix operator *> : RunesApplicativeSequencePrecedence

/**
an associative binary operation
Expected function type: `f a -> f a -> f a`
Haskell `infixl 3`
*/
infix operator <|> : AlternativePrecedence
infix operator <|> : RunesAlternativePrecedence

/**
map a function over a value with context and flatten the result
Expected function type: `m a -> (a -> m b) -> m b`
Haskell `infixl 1`
*/
infix operator >>- : MonadicPrecedenceLeft
infix operator >>- : RunesMonadicPrecedenceLeft

/**
map a function over a value with context and flatten the result
Expected function type: `(a -> m b) -> m a -> m b`
Haskell `infixr 1`
*/
infix operator -<< : MonadicPrecedenceRight
infix operator -<< : RunesMonadicPrecedenceRight

/**
compose two functions that produce results in a context,
Expand All @@ -91,7 +91,7 @@ from left to right, returning a result in that context
Expected function type: `(a -> m b) -> (b -> m c) -> a -> m c`
Haskell `infixr 1`
*/
infix operator >-> : MonadicPrecedenceRight
infix operator >-> : RunesMonadicPrecedenceRight

/**
compose two functions that produce results in a context,
Expand All @@ -102,4 +102,4 @@ like `>->`, but with the arguments flipped
Expected function type: `(b -> m c) -> (a -> m b) -> a -> m c`
Haskell `infixr 1`
*/
infix operator <-< : MonadicPrecedenceRight
infix operator <-< : RunesMonadicPrecedenceRight
2 changes: 1 addition & 1 deletion Tests/Runes/Operators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Runes

precedencegroup CompositionPrecedence {
associativity: right
higherThan: ApplicativeSequencePrecedence
higherThan: RunesApplicativeSequencePrecedence
}

infix operator : CompositionPrecedence
Expand Down

0 comments on commit 5c07ea7

Please sign in to comment.