Proposal: Add singleton function to Data.List module
Andreas Abel
andreas.abel at ifi.lmu.de
Tue Aug 20 09:46:25 UTC 2019
Right, but the ones you quote are all variants of sequences, not
collections in general. They have append and cons. An interface for
sequences should name these operations uniformly. However, I would
restrict the current discussion to construction of collections in
general, with the interface
mempty -- construct an empty collection
singleton -- construct a collection with one element
mappend -- join two collections
There is a (next to virginal) attempt to define an API for collections at
http://hackage.haskell.org/package/collections-api-1.0.0.0/docs/Data-Collections.html
Incidentally, it has
singleton :: i -> c
Creates a collection with a single element.
Cheers,
Andreas
On 2019-08-19 12:38, Helmut Schmidt wrote:
> Andreas, you seem to be mistaken there'd only be one container API? But
> there's several container APIs besides "Data.Set" which provide some
> collection of elements!
>
> https://hackage.haskell.org/package/dlist-0.8.0.7/docs/Data-DList.html#v:cons
>
> https://hackage.haskell.org/package/dlist-0.8.0.7/docs/Data-DList.html#v:append
>
> https://hackage.haskell.org/package/text-1.2.4.0/docs/Data-Text.html#v:cons
>
> https://hackage.haskell.org/package/text-1.2.4.0/docs/Data-Text.html#v:append
>
> http://hackage.haskell.org/package/vector-0.12.0.3/docs/Data-Vector.html#v:cons
>
> https://hackage.haskell.org/package/bytestring-0.10.10.0/docs/Data-ByteString.html#v:cons
>
> https://hackage.haskell.org/package/bytestring-0.10.10.0/docs/Data-ByteString.html#v:append
>
> Am Mo., 19. Aug. 2019 um 08:16 Uhr schrieb Andreas Abel
> <andreas.abel at ifi.lmu.de <mailto:andreas.abel at ifi.lmu.de>>:
>
> Helmut, do you actually know the container APIs?
>
> Show me cons and append in Data.Set!
>
> On 2019-08-18 19:40, Helmut Schmidt wrote:
> >
> >
> > Am So., 18. Aug. 2019 um 17:17 Uhr schrieb Oliver Charles
> > <ollie at ocharles.org.uk <mailto:ollie at ocharles.org.uk>
> <mailto:ollie at ocharles.org.uk <mailto:ollie at ocharles.org.uk>>>:
> >
> > On Sun, 18 Aug 2019, 5:47 pm Helmut Schmidt,
> > <helmut.schmidt.4711 at gmail.com
> <mailto:helmut.schmidt.4711 at gmail.com>
> > <mailto:helmut.schmidt.4711 at gmail.com
> <mailto:helmut.schmidt.4711 at gmail.com>>> wrote:
> >
> >
> > All these philosophical arguments calling for
> "consistency" with
> > the container APIs or that function need words for the human
> > mind to comprehend seem short-sighted to me. If we were
> > consistent about the proposal itself we'd also demand to add
> >
> > cons = (:)
> >
> > empty = []
> >
> > toList = id
> >
> > fromList = id
> >
> >
> > I honestly have no problem with any of these.
> >
> >
> > I forgot
> >
> > append = (++)
> >
> > We also need to address another elephant in the room... those pesky
> > tuples and their special privileged non-wordy syntax!
> >
> > pair = (,)
> >
> > triple = (,,)
> >
> > quadruple = (,,,)
> >
> > quituple = (,,,,)
> >
> > sextuple = (,,,,,)
> >
> > septuble = (,,,,,,)
> >
> > octuple = (,,,,,,,)
> >
> > If Haskell were invented in this century's EU Haskell source code
> would
> > be littered with €s instead of $s but then again I wonder why £
> wasn't
> > picked. But I digress. We can kill two birds with one stone here:
> >
> > apply = ($)
> >
> > strictApply = ($!)
> >
> > compose = (.)
> >
> >
> > It's fun to imagine how code using those definitions would like! But
> > it's still a -1 for me, sorry!
> >
> >
> >
> >
> > _______________________________________________
> > Libraries mailing list
> > Libraries at haskell.org <mailto:Libraries at haskell.org>
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
> >
>
More information about the Libraries
mailing list