-
Notifications
You must be signed in to change notification settings - Fork 37
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
Don't export fst
(and alike) from Prelude.Linear
#405
Comments
There is a reason why we export these versions of The reason is that it's consistent with the behaviour of record types:
We have: MkPair :: a %1 -> b %1 -> Pair a b
fst :: Pair a b -> a
snd :: Pair a b -> b This is the only type that we can give to I should say, more generally, that I'm always rather suspicious of functions with After reading this what are your thoughts? |
I agree that for arbitrary records, linear projects would be awkward (needing one So, the remaining option would be to not export I think what deepened my confusion is that I misread the index (https://hackage.haskell.org/package/linear-base-0.2.0/docs/doc-index-F.html), which lists
I was somehow assuming that this is the same function exported twice, but I should have looked more carefully to recognize that these are different functions (nice if the index gave the type signatures...). Not sure what to recommend. It might just be a beginner's learning experience. |
Hey, I'm back 🙂 Looking at it with fresher eyes, I think that the mistake is using the names from fst :: Consumable b => (a, b) %1 -> a As it can be argued that it doesn't have the expected behaviour. Ironically it could be called |
I think my expectation was that this is just import Prelude as NonLinear
-- OR: import Prelude.NonLinear as NonLinear / as Ur / as U
import qualified Prelude.Linear as Linear / as L
...
... fst ...
... NonLinear.fst ... (Ur.fst) (U.fst)
... Linear.fst ... (L.fst) However, atm |
For whatever it's worth, I have a slight preference for |
I agree. However, my fear is that it's not really generalisable: how would we name the list-zipping functions, then? |
Similarly, would |
It is surprising that
Prelude.Linear
exports the non-linear version of projectionfst :: (a,b) -> a
.This tripped me up (with non-inspiring errors about multiplicity) when writing
evalState
:evalState
(toControl.Functor.Linear
) #404I was naturally expecting that
fst :: Consumable b => (a,b) -> a
would be by default in scope if afst
is in scope. After all, we want linear programs when we importPrelude.Linear
!So, I suggest either to not export
fst
(and alike) or export them fromData.Tuple.Linear
.The text was updated successfully, but these errors were encountered: