Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:06:04+00:00 2026-06-17T19:06:04+00:00

It seems I don’t understand how text index in IxSet should work. Here, I

  • 0

It seems I don’t understand how text index in IxSet should work. Here, I created a unit-test that indexes items by tags field, and then query items by tag “tag”. It should (from my perspective) give me back all 3 items (because they all have tag “tag”), but seems they don’t. And I don’t understand why.

{-# LANGUAGE DeriveDataTypeable #-}

import Test.HUnit
import Data.IxSet
import Data.List.Split ( splitOn )
import Data.Data ( Data, Typeable )

data TaggedItem = TaggedItem { getTags :: String }
                  deriving ( Show, Ord, Eq, Data, Typeable )

data Tag = Tag String
           deriving ( Show, Ord, Eq, Data, Typeable )

getTagStrings :: TaggedItem -> [Tag]
getTagStrings = map Tag . splitOn "," . getTags

instance Indexable TaggedItem where
  empty = ixSet
            [ ixFun getTagStrings ]

test3 = TestCase (
  assertEqual "ixFun multiple tags test"
  3
  (size (index @= (Tag "tag"))) )
  where items = [ TaggedItem "tag,tag1,tag2"
                , TaggedItem "tag,tag1,tag2"
                , TaggedItem "tag,tag1,tag2" ]
        index = fromList items

tests = TestList [
  -- TestLabel "test1" test1,
  -- TestLabel "test2" test2,
  TestLabel "test3" test3]

main = do
  runTestTT tests

Update:

Hmm, quite interesting. I’ve added field “name” and made at each item name to be different, and now it works.

{-# LANGUAGE DeriveDataTypeable #-}

import Test.HUnit
import Data.IxSet
import Data.List.Split ( splitOn )
import Data.Data ( Data, Typeable )

newtype TaggedItemName = TaggedItemName { unTaggedItemName :: String }
                       deriving ( Show, Ord, Eq, Data, Typeable )

data TaggedItem = TaggedItem { getName :: TaggedItemName, getTags :: String }
                deriving ( Show, Ord, Eq, Data, Typeable )

data Tag = Tag String
           deriving ( Show, Ord, Eq, Data, Typeable )

getTagStrings :: TaggedItem -> [Tag]
getTagStrings = map Tag . splitOn "," . getTags

instance Indexable TaggedItem where
  empty = ixSet
            [ ixFun getTagStrings ]

test3 = TestCase (
  assertEqual "ixFun multiple tags test"
  3
  (size (index @= (Tag "tag"))) )
  where items = [ TaggedItem (TaggedItemName "name1") "tag,tag1,tag2"
                , TaggedItem (TaggedItemName "name2") "tag,tag1,tag2"
                , TaggedItem (TaggedItemName "name3") "tag,tag1,tag2" ]
        index = fromList items

tests = TestList [
  -- TestLabel "test1" test1,
  -- TestLabel "test2" test2,
  TestLabel "test3" test3]

main = do
  runTestTT tests

Works. So maybe IxSet considered those items as same and merged them somehow (?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:06:05+00:00Added an answer on June 17, 2026 at 7:06 pm

    Yes, it seems IxSet merges equal values. I took first example and changed it so that it did:

      where items = [ TaggedItem "tag,tag1,tag2"
                    , TaggedItem "tag,tag3,tag4"
                    , TaggedItem "tag,tag5,tag6" ]
    

    And now it also works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't quite understand whats happening here a=[1,2,3,4] b=[5,6,7,8] a[len(a):] = b seems to
I've heard that GAE now supports Groovy, but it seems the plugins don't work
It seems that I don't understand the meaning of the in keyword in JavaScript.
Hi I have a issue respect a hbm2ddl.import_files, it seems that don't work and
I have tried many permutations but they all don't seems to work well. Am
I don't understand why the code isn't working, and nothing I found seems to
Alright I don't see why this isnt working. It seems pretty simple. Here is
It seems I don't understand IPTABLES logic. I reinstalled ubuntu server 11.10 on my
I thought that I understood php arrays, but it seems I don't :( This
GWT RPC call don't seems to work when i deploy my war file to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.