Possible bug in filter #33

Closed
tibbe opened this Issue Mar 13, 2012 · 2 comments

Comments

Projects
None yet
1 participant
Owner

tibbe commented Mar 13, 2012

The following example should print True twice:

test.hs

{-# LANGUAGE DeriveDataTypeable #-}
import Data.Data
import Data.Protobuf.AST
import Data.Protobuf.Types

import qualified Data.HashSet as Set

main :: IO ()
main = do
    let h1 = Set.fromList $ good
        h2 = Set.filter (`elem` good) h1  -- same as h1
    print $ Set.member (head good) h1
    print $ Set.member (head good) h2


good = [typeOf (undefined :: [ProtobufFile Namespace])
       ,typeOf (undefined :: Message)
       ,typeOf (undefined :: [Message])
       ]

Data/Protobuf/AST.hs

{-# LANGUAGE DeriveDataTypeable #-}
module Data.Protobuf.AST where

import Data.Data


data ProtobufFile n
  = ProtobufFile [Message] n
    deriving (Show,Typeable,Data)

data Message = Message
               (Identifier)
               [MessageField]
               [Identifier]
               deriving (Show,Typeable,Data)

data MessageField
  = MessageField Field
  | Nested Message
  deriving (Show,Typeable,Data)

data Field = Field
             deriving (Show,Typeable,Data)

newtype Identifier = Identifier String
    deriving (Typeable,Data,Show)

Data/Protobuf/Types.hs

{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
-- | Data types for transformations
module Data.Protobuf.Types (
    Namespace
  , emptyNamespace
  ) where


import Data.Data                 (Typeable,Data)
import qualified Data.Map      as Map
import           Data.Map        (Map)

-- | Namespace
newtype Namespace = Namespace (Map String Int)
                  deriving (Typeable,Data)

-- | Empty namespace
emptyNamespace :: Namespace
emptyNamespace = Namespace Map.empty

@tibbe tibbe closed this in 23b86f8 Mar 13, 2012

Owner

tibbe commented Mar 13, 2012

I will make a new release that includes this bugfix in the next few days.

Owner

tibbe commented Mar 14, 2012

I've released 0.2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment