Discussion:
Generalize "set" operations from Data.List
Add Reply
Dannyu NDos
2018-11-01 02:53:03 UTC
Reply
Permalink
I've suffered from inconvenience due to the restricted type signature. I'll
be very glad if such restrictions are lifted:

deleteBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> a -> [b] -> [b]
deleteFirstsBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [b]
intersectBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [a]

I approve these versions because:
1. It makes more sense that the "usual" `delete` and `intersect` functions
are specialization of the "By" operations, not the vice versa.
2. Data.Map.Lazy module from *containers* package has these kind of "By"
operations.

The previous discussion about this in Sep 2016 didn't make much conclusion,
so let the discussion continue.
David Feuer
2018-11-01 02:58:08 UTC
Reply
Permalink
I don't think it's really so great that Data.List has a bunch of operations
that are inefficient on lists.
Post by Dannyu NDos
I've suffered from inconvenience due to the restricted type signature.
deleteBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> a -> [b] -> [b]
deleteFirstsBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [b]
intersectBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [a]
1. It makes more sense that the "usual" `delete` and `intersect` functions
are specialization of the "By" operations, not the vice versa.
2. Data.Map.Lazy module from *containers* package has these kind of "By"
operations.
The previous discussion about this in Sep 2016 didn't make much
conclusion, so let the discussion continue.
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Dannyu NDos
2018-11-01 03:03:11 UTC
Reply
Permalink
It would be more ineffecient if I had to convert my lists to Data.Sets ot
Data.Maps every time... For small lists, the operations are simple and
practical. This doesn't have anything with generalization of type
signatures anyway.
Post by David Feuer
I don't think it's really so great that Data.List has a bunch of
operations that are inefficient on lists.
Post by Dannyu NDos
I've suffered from inconvenience due to the restricted type signature.
deleteBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> a -> [b] -> [b]
deleteFirstsBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [b]
intersectBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [a]
1. It makes more sense that the "usual" `delete` and `intersect`
functions are specialization of the "By" operations, not the vice versa.
2. Data.Map.Lazy module from *containers* package has these kind of "By"
operations.
The previous discussion about this in Sep 2016 didn't make much
conclusion, so let the discussion continue.
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Vanessa McHale
2018-11-01 03:17:08 UTC
Reply
Permalink
Isn't deleteBy achievable via a filter?
Post by Dannyu NDos
It would be more ineffecient if I had to convert my lists to Data.Sets
ot Data.Maps every time... For small lists, the operations are simple
and practical. This doesn't have anything with generalization of type
signatures anyway.
I don't think it's really so great that Data.List has a bunch of
operations that are inefficient on lists.
I've suffered from inconvenience due to the restricted type
deleteBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> a -> [b] -> [b]
deleteFirstsBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [b]
intersectBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [a]
1. It makes more sense that the "usual" `delete` and
`intersect` functions are specialization of the "By"
operations, not the vice versa.
2. Data.Map.Lazy module from *containers* package has these
kind of "By" operations.
The previous discussion about this in Sep 2016 didn't make
much conclusion, so let the discussion continue.
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Dannyu NDos
2018-11-01 03:22:28 UTC
Reply
Permalink
filter erases all elements not satisfying given predicate. deleteBy erases
only the first element satisfying given predicate.
Post by Vanessa McHale
Isn't deleteBy achievable via a filter?
It would be more ineffecient if I had to convert my lists to Data.Sets ot
Data.Maps every time... For small lists, the operations are simple and
practical. This doesn't have anything with generalization of type
signatures anyway.
Post by David Feuer
I don't think it's really so great that Data.List has a bunch of
operations that are inefficient on lists.
Post by Dannyu NDos
I've suffered from inconvenience due to the restricted type signature.
deleteBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> a -> [b] -> [b]
deleteFirstsBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [b]
intersectBy :: (a -> b -> Bool
<http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bool.html#t:Bool>)
-> [a] -> [b] -> [a]
1. It makes more sense that the "usual" `delete` and `intersect`
functions are specialization of the "By" operations, not the vice versa.
2. Data.Map.Lazy module from *containers* package has these kind of
"By" operations.
The previous discussion about this in Sep 2016 didn't make much
conclusion, so let the discussion continue.
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Loading...