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
Introduce idiomatic operators and revisit fixities for existing ones #57
Comments
I'd really like to get |
FWIW I don't find that these
Trying to make
|
@tomjaguarpaw I think it worked well enough here: https://github.com/ocharles/zero-to-quake-3/blob/master/src/Quake3/Vertex.hs#L28,L40. Sure, the tupling is a bit inconvenient, but it's not too bad. |
Wouldn't you prefer vertexFormat :: VertexFormat Vertex
vertexFormat =
contramap vPos v3_32sfloat
<> contramap vSurfaceUV v2_32sfloat
<> contramap vLightmapUV v2_32sfloat
<> contramap vNormal v3_32sfloat
<> contramap vColor v4_8uint ? |
My 2c w.r.t. operator symbols - it would be more intuitive if the
However, that isn't a perfect scheme because if you have Perhaps the arrowheads can be kept flipped for consistency, but using
Perhaps this scheme might break consistency with other things; in that case feel free to ignore my comment 😅 . |
I think the duality with Applicative is a good reason to retain the |
@tomjaguarpaw that's a fair point. At first I wanted to reply with "No! That would let me rearrange things such that they don't follow the shape of the data type!". But now that I think about it... I'm not sure I care about that. I do care about the order of the |
Something I appreciate about In contravariant land, I find the I prefer the tuple and Since I don't find one style strictly superior, I think both should exist. I'll write a bit here about why I chose to use |
Here's a little utility that can help with data Engine = Pistons Int | Rocket
deriving (Generic, Show)
data Car = Car
{ carMake :: String
, carModel :: String
, carEngine :: Engine
, carYears :: Int
} deriving (Generic)
You can then use generic ghci> :t adapt @Engine
adapt @Engine :: Engine -> Either Int ()
ghci> adapt (Pistons 3)
Left 3
ghci> adapt Rocket
Right ()
ghci> :t adapt @Car
adapt @Car :: Car -> (([Char], [Char]), (Engine, Int))
ghci> adapt (Car "foo" "bar" Rocket 3)
(("foo","bar"),(Rocket,3)) GHC rebalances generic representation, so for And here is the implementation: This is my first |
@gwils: If you write in doAThing (Vector x y z w) = thing x <> thing y <> thing z <> thing w then you will indeed get a compiler error when your datatype changes. |
That's true, I'll keep it in mind. Rereading the thread, I notice that that style isn't an alternative way to work with Being able to use |
It would be really great if this was resolved. The open questions seem to be:
|
Yes, there's |
I'd like to see some real-life use-cases of the |
I also just noticed that |
I believe, part of this issue is resolved by @Gabriel439, specifically: For reference, here is the recent blog post that describes the technique and convenience of using the |
I'm still baffled why |
i admit the fixity change is the only real problem i have with adding these as is. |
i like this move a lot. |
The problem with the What happens if we shift the priorities up by one everywhere? |
#71 adds the operators |
This year talk by @gwils introduced operators for Contravariant family of typeclasses (
Contravariant/Divisible/Decidable
) and gave example of how this can be used for pretty-printing library:Specifically:
With the following fixity declarations:
Unfortunately, this conflicts with fixities for existing operator:
The proposal was discussed under the following Twitter thread:
/cc @gwils @vrom911
P.S. I also propose to rename
>$$<
to>&<
to have naming more consistent with existing operators.The text was updated successfully, but these errors were encountered: