-
Notifications
You must be signed in to change notification settings - Fork 16
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
Make the DList type abstract #4
Comments
I did a quick search of Hackage to see which packages are using @basvandijk What do you think about this? Your |
Good point. Lets make DList abstract. However I think we can keep the export of With regards to |
True, only the constructor is unsafe, not the deconstructor, so we can still use apply :: DList a -> [a] -> [a]
undlist
toList'
toListFunction
toListFun
toFunction
fromDList I think I prefer |
I like |
You actually can use x = empty { unDL = \z -> z ++ z } The same is not true for |
Excellent point, @dag. Thanks! |
Change Log ========== Version 0.6 (2013-11-29) *Black Friday* --------------------------------------- #### Development changes * Maintenance and development taken over by Sean Leather * Migrate repository from http://code.haskell.org/~dons/code/dlist/ to https://github.com/spl/dlist #### Package changes * Stop supporting `base < 2` * Fix tests and use `cabal test` * Add scripts for running `hpc` * Update documentation #### New features * New type class instances: `Eq`, `Ord`, `Read`, `Show`, `Alternative`, and `Foldable` * New function `apply` to use instead of `unDL` #### Deprecations * Deprecate DList constructor and record selector to make it abstract (see [#4](spl/dlist#4)) * Deprecate `maybeReturn` which is not directly relevant to dlists
I found unDL in planar-graph and substituted apply. What is the preferred syntax? Tnx. |
@jimstutt |
It was @dag's comment "Thus, whenever unDL is removed, this should not be done by renaming it to apply." which prompted me to ask. I'll just use apply. |
@jimstutt Sorry for the late response here, but anyway: what I meant was that when unDL is removed from the dlist package itself it's not enough to simply rename the record field and export the new name, because record fields can be used as setters, and can be used to break module boundaries otherwise imposed by private constructors. My remark was not meant to say anything about code using the dlist package. Hope that clears it up! |
Thanks dag. I'll have to revisit the code. |
Use recommendation in https://prime.haskell.org/wiki/Libraries/Proposals/SemigroupMonoid to support different GHC versions for Semigroup and Monoid. Remove SAFE.
DList a
is isomorphic to[a]
viafromList
/toList
, but[a] -> [a]
is not isomorphic to[a]
. That is, all lists are dlists, and all dlists are lists only if there is no way to construct ay :: DList a
from an "unsafe"x :: [a] -> [a]
.Currently, the library exports the constructor
DL
and deconstructorunDL
which allows the construction of unsafe dlist values. Consider this GHCi session:The values of
x
andtoList x
are clearly not isomorphic. When used:DList
was abstract early on. I don't know why it was changed.To preserve the isomorphism, I think
DList
should be an abstract type and the constructor and deconstructor should be removed from the export list.The text was updated successfully, but these errors were encountered: