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 8934083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:42:07+00:00 2026-06-15T09:42:07+00:00

I’m using the list-tries package : import qualified Data.ListTrie.Patricia.Map as TM import qualified Data.ListTrie.Patricia.Set

  • 0

I’m using the list-tries package:

import qualified Data.ListTrie.Patricia.Map as TM
import qualified Data.ListTrie.Patricia.Set as TS
import qualified Data.Map as Map

I have a list of strings, which I want to store in a Trie-Map consisting of Trie-Sets, like this:

-- vocabs :: [String]
trie = TM.fromListWith' (flip TS.union) $ map (\v->(sort v, TS.singleton v)) vocabs

(this is for looking up a set of letters in the outer trie, then looking up a specific combination of letters in the resulting trie).

I can understand that Haskell does not know which exact type the trie has, because I have nowhere specified which type of map to use. I thought I could do this by adding the declaration

trie :: TM.TrieMap Map.Map Char (TS.TrieSet Map.Map Char)

but it seems not to be enough. I’m still getting error messages like

No instance for (Data.ListTrie.Base.Map.Map Map.Map Char)
arising from a use of TrieM.fromListWith'

Possible fix:
add an instance declaration for
(Data.ListTrie.Base.Map.Map Map.Map Char)

In the expression: TrieM.fromListWith' TrieS.union

In the expression: …

and similar ones for the of TS.singleton, TM.lookup, TS.member and TS.findMin.

I don’t seem to get the actual problem, and also don’t know how to add type declaration to [inline] expressions (I’ve seen it a few times, but didn’t get the syntax). Could you please help me out?

  • 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-15T09:42:08+00:00Added an answer on June 15, 2026 at 9:42 am

    I can’t reproduce the problem.

    Without the signature for trie, I get – unsurprisingly – an ambiguous type variable error (well, two), for the reason stated in the question, together with a possible cause (that really is the cause, it’s the monomorphism restriction), and two probable fixes (disabling the monomorphism restriction makes it compile, but giving an explicit type signature is the better fix). The error message is appended below for overinterested souls (it’s from 7.6.1).

    With the type signature, it compiles cleanly.

    In the light of that, I cannot diagnose the problem with certainty, but experience together with the error message you got provide a probable cause.

    You got a very specific message that the required instance is not in scope:

    No instance for (Data.ListTrie.Base.Map.Map Map.Map Char) arising from a use of TrieM.fromListWith'
    
    Possible fix: add an instance declaration for (Data.ListTrie.Base.Map.Map Map.Map Char)
    

    On the other hand, the list-tries package explicitly provides such an instance.

    The typical cause for such a situation is that there are two distinct classes or two distinct types involved that come from different versions of the same package.

    In this case, you have likely built list-tries against one version of containers, and later installed a different version of containers, and the import qualified Data.Map as Map imports the Map.Map type from the newer package version, while the instance in list-tries is for the older version.

    Check whether you have more than one version of containers installed with

    ghc-pkg list containers
    

    Check on which version of containers your list-tries depends with

    ghc-pkg describe list-tries
    

    In the depends field of the output of that, there will appear something like

    containers-0.5.0.0-e49be7a240765a4edc5c09f677ec6a81
    

    listing the package version and the ABI hash of the containers package list-tries was built with.

    If the version doesn’t correspond to the newest version of containers you have installed, the above situation arises unless the version of containers to use is explicitly specified when invoking GHC, either directly with a -package flag, or indirectly via a .cabal file.

    If that is the case, you can

    • explicitly specify the version of containers to use every time you use list-tries
    • unregister the newer version(s)of containers (could break other packages)
    • rebuild list-tries against the newer version of containers

    TrieTest.hs:12:8:
        No instance for (Data.ListTrie.Base.Map.Map map0 Char)
          arising from a use of TM.fromListWith'
        The type variable `map0' is ambiguous
        Possible cause: the monomorphism restriction applied to the following:
          trie :: TM.TrieMap map0 Char (TS.TrieSet map1 Char)
            (bound at TrieTest.hs:12:1)
        Probable fix: give these definition(s) an explicit type signature
                      or use -XNoMonomorphismRestriction
        Note: there are several potential instances:
          instance Eq k =>
                   Data.ListTrie.Base.Map.Map Data.ListTrie.Base.Map.AList k
            -- Defined in `Data.ListTrie.Base.Map'
          instance Ord k => Data.ListTrie.Base.Map.Map Map.Map k
            -- Defined in `Data.ListTrie.Base.Map'
          instance Enum k =>
                   Data.ListTrie.Base.Map.Map Data.ListTrie.Base.Map.WrappedIntMap k
            -- Defined in `Data.ListTrie.Base.Map'
        Possible fix:
          add an instance declaration for
          (Data.ListTrie.Base.Map.Map map0 Char)
        In the expression: TM.fromListWith' (flip TS.union)
        In the expression:
          TM.fromListWith' (flip TS.union)
          $ map (\ v -> (sort v, TS.singleton v)) vocabs
        In an equation for `trie':
            trie
              = TM.fromListWith' (flip TS.union)
                $ map (\ v -> (sort v, TS.singleton v)) vocabs
    
    TrieTest.hs:12:31:
        No instance for (Data.ListTrie.Base.Map.Map map1 Char)
          arising from a use of `TS.union'
        The type variable `map1' is ambiguous
        Possible cause: the monomorphism restriction applied to the following:
          trie :: TM.TrieMap map0 Char (TS.TrieSet map1 Char)
            (bound at TrieTest.hs:12:1)
        Probable fix: give these definition(s) an explicit type signature
                      or use -XNoMonomorphismRestriction
        Note: there are several potential instances:
          instance Eq k =>
                   Data.ListTrie.Base.Map.Map Data.ListTrie.Base.Map.AList k
            -- Defined in `Data.ListTrie.Base.Map'
          instance Ord k => Data.ListTrie.Base.Map.Map Map.Map k
            -- Defined in `Data.ListTrie.Base.Map'
          instance Enum k =>
                   Data.ListTrie.Base.Map.Map Data.ListTrie.Base.Map.WrappedIntMap k
            -- Defined in `Data.ListTrie.Base.Map'
        Possible fix:
          add an instance declaration for
          (Data.ListTrie.Base.Map.Map map1 Char)
        In the first argument of `flip', namely `TS.union'
        In the first argument of TM.fromListWith', namely `(flip TS.union)'
        In the expression: TM.fromListWith' (flip TS.union)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.