-
Notifications
You must be signed in to change notification settings - Fork 88
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
Please, how is Pos not a Monoid #450
Comments
It's up to you if you want to reuse the type in your programs. For the particular problem you show you could simply do a conditional function application: if <something>
then r1 <> r2
else r1 <> r2 <> ... |
Not percieved a mathematical argumentation there. Addition of course forms a Monoid with Concept of positioning embodies Since Just not wanted to invent own code. My idea was that Of course the question also can be solved by more code. This question is an old one in parsers. Of course I consider those are a silly arguments, and you probably know the question better. Well. Discussion seems was established into a dead end. Ok then. I would go either way. Was worth a shot. Thank you for correspondence. |
If function has a switch to include region or not, or if function counts a number of regions to compose-accumulate them into
SrcSpan
region:SrcSpan
isSemigroup
, it is notMonoid
, becauseMegaparsec: Pos
prevents it from beingMonoid
,mkPos
constructor preventsPos
from being0
, and so making impossible to declare aMonoid
for any types that contain it.Is it possible to allow
Pos 0
, so theMonoid
s can be created above (at least I mean in dependent projects code)?Maybe, at lease it is possible to provide a side-builder,
{mempty,zero}Pos
, that yealdsPos 0
?Or maybe I do something wrong and there is much more effective way?
Question originally derived from:
https://github.com/haskell-nix/hnix/blob/9f873ca115a32d462b6c0cfec771ecbf1d292c6c/src/Nix/Expr/Types/Annotated.hs#L142-L146
The text was updated successfully, but these errors were encountered: