Giter Club home page Giter Club logo

hmap's People

Contributors

atzeus avatar pmlodawski avatar schell avatar traviswhitaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hmap's Issues

Hackage love?

Hi @atzeus,
Any chance you'd like to upload the current master to hackage? The version there still suffers from the issue fixed in #10.

Unsound type

Related to #12
The same wrapping trick can get us an unsound type.
In the following we show that Char 'a' can be unsafely cast to Int 97.
Changing Int to (Int,Int) causes a seg fault.

Nick

{-#LANGUAGE ExistentialQuantification, RankNTypes #-}
module Main(main) where

import Data.HMap(HKey,HMap)
import qualified Data.HMap as HMap

data Wrapped a = forall x. Wrap (HKey x a)

w :: Wrapped a
w = HMap.withKey Wrap

hmap :: HMap
hmap = case w of Wrap k -> HMap.insert k 'a' HMap.empty

res :: Maybe Int -- replace Int with (Int,Int) for seg fault!
res = case w of Wrap k -> HMap.lookup k hmap

main :: IO ()
main = do
  print res

{- Prints...
Just 97
-}

Implicit use of weak pointers causing memory issues

Hi!
Why is this library using weak pointers, from key to value?

When we add values to a map, there is no option to remove them from memory and they are stuck there until the key is deleted too. There are many use cases that you cannot remove the key (e.g updating value in a map) and need your app not too eat all the RAM.

Loss of referential transparency

The doc for HKey.withKey states:

"The implementation actually creates a key, but because the key cannot escape the given function f, there is no way to observe that if we run withKey f twice, that it will get a different key the second time."

But in the following we see it is possible.

Nick

{-#LANGUAGE ExistentialQuantification, RankNTypes #-}
module Main(main) where

import Data.HMap as HMap

data Wrapped = forall x. Wrapped (HKey x ())

create :: () -> Wrapped
create () = HMap.withKey Wrapped

x,y,z :: Wrapped
x = create ()
y = create ()
z = y

comp :: Wrapped -> Wrapped -> Bool
comp (Wrapped key1) (Wrapped key2) = HMap.unique key1 == HMap.unique key2

main :: IO ()
main = do
  print ("x~y",comp x y)
  print ("x~z",comp x z)
  print ("y~z",comp y z)

{- Prints...
("x~y",False)
("x~z",False)
("y~z",True)
-}

Not in scope: type constructor or class ‘Foldable’

Hi! It looks like master version have some compile issues

Resolving dependencies...
Notice: installing into a sandbox located at
/home/pmlodawski/dev/projects/HMap/.cabal-sandbox
Configuring text-1.2.1.1...
Configuring transformers-0.4.3.0...
Building text-1.2.1.1...
Building transformers-0.4.3.0...
Installed transformers-0.4.3.0
Configuring mtl-2.2.1...
Building mtl-2.2.1...
Installed mtl-2.2.1
Installed text-1.2.1.1
Configuring hashable-1.2.3.2...
Building hashable-1.2.3.2...
Installed hashable-1.2.3.2
Configuring unordered-containers-0.2.5.1...
Building unordered-containers-0.2.5.1...
Installed unordered-containers-0.2.5.1
Configuring HMap-1.2.3...
Building HMap-1.2.3...
Failed to install HMap-1.2.3
Build log ( /home/pmlodawski/dev/projects/HMap/.cabal-sandbox/logs/HMap-1.2.3.log ):
Configuring HMap-1.2.3...
Building HMap-1.2.3...
Preprocessing library HMap-1.2.3...
[1 of 6] Compiling Data.HideType    ( Data/HideType.hs, dist/dist-sandbox-47edc933/build/Data/HideType.o )
[2 of 6] Compiling Data.HKeyPrivate ( Data/HKeyPrivate.hs, dist/dist-sandbox-47edc933/build/Data/HKeyPrivate.o )
[3 of 6] Compiling Data.Untypeable  ( Data/Untypeable.hs, dist/dist-sandbox-47edc933/build/Data/Untypeable.o )
[4 of 6] Compiling Data.HKey        ( Data/HKey.hs, dist/dist-sandbox-47edc933/build/Data/HKey.o )
[5 of 6] Compiling Data.HMap        ( Data/HMap.hs, dist/dist-sandbox-47edc933/build/Data/HMap.o )
[6 of 6] Compiling Data.HKeySet     ( Data/HKeySet.hs, dist/dist-sandbox-47edc933/build/Data/HKeySet.o )

Data/HKeySet.hs:75:11:
    Not in scope: type constructor or class ‘Foldable’
cabal: Error: some packages failed to install:
HMap-1.2.3 failed during the building phase. The exception was:
ExitFailure 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.