[Haskell-beginners] Map instances in the list-tries package
Matthew Moppett
matthewmoppett at gmail.com
Mon Dec 19 16:52:10 CET 2011
Thanks a lot, Stephen - was just about giving up on this.
The correct type signature turned out to be:
import Data.ListTrie.Patricia.Map as P
import qualified Data.Map as Map
a :: P.TrieMap Map.Map Char Int
a = P.singleton "harry" 99
On Tue, Dec 20, 2011 at 1:07 AM, Stephen Tetley <stephen.tetley at gmail.com>wrote:
> Hi Matthew
>
> You'll have to give `a` a concrete type, as `singleton` is overloaded,
> GHC cannot infer a type.
>
> The TrieMap type is quite complicated as it allows different
> representations of (finite) Maps within it. There are three different
> internal maps you can use (the three pre-defined instances of the Map
> class - Data.Map, WrappedIntMap and AList) - I'd go for Data.Map as it
> will be faster than AList and I think you are using Char for key so
> you can't use an IntMap.
>
> I don't have the package `list-tries` installed but I'd guess at one
> of these two for the concrete type signature.
>
> Assuming you have imported Data.Map as
>
> import qualified Data.Map as Map
>
> (Probably this...)
> a :: TrieMap Map.Map [Char] Int
>
>
> (Possibly this...)
> a :: TrieMap (Map.Map Char Int) [Char] Int
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111220/6773de06/attachment.htm>
More information about the Beginners
mailing list