Commitment Activities

Okay, so this is a stupid question. I defined a new # operator, and I'm trying to figure out what the hell should be a commit declaration.

  • I want # applied after ++ . Does this mean that priority should be higher or lower than ++ ? ( ++ has priority 5.)

  • Type (#) :: Foo -> Bar -> Foo . Do I need a left-associative or a right-associative? Because it seems to me that one of them will do a check like x # y # z , and the other will not.

I know this may seem trivial, but I always always make mistakes ...

+7
haskell
source share
1 answer
  • $ has the lowest priority (0) and $ always applies the "last", so you want # have a lower priority than ++ . In addition, you can compare priority * and + .

  • Left associativity means that x # y # z = (x # y) # z (the left sphere acts in the same way). x # (y # z) will not enter a check, but (x # y) # z will, so you want it to remain associative.

+9
source share

All Articles