[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-beginners
Subject:    Re: [Haskell-beginners] Map instances in the list-tries package
From:       Matthew Moppett <matthewmoppett () gmail ! com>
Date:       2011-12-19 15:52:10
Message-ID: CAMLEjZBOvf1EbvUn7TWA54D64-fMw_zfnx_=f7ygsqqVZOEZfg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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
>

[Attachment #5 (text/html)]

Thanks a lot, Stephen - was just about giving up on this.<div><br></div><div>The \
correct type signature turned out to be:</div><div><br></div><div><div>import \
Data.ListTrie.Patricia.Map as P</div><div>import qualified Data.Map as Map</div> \
<div><br></div><div>a :: P.TrieMap Map.Map Char Int</div><div>a = P.singleton \
&quot;harry&quot; 99</div><div><br></div><div><br><br><div class="gmail_quote">On \
Tue, Dec 20, 2011 at 1:07 AM, Stephen Tetley <span dir="ltr">&lt;<a \
href="mailto:stephen.tetley@gmail.com">stephen.tetley@gmail.com</a>&gt;</span> \
wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex">Hi Matthew<br> <br>
You&#39;ll have to give `a` a concrete type, as `singleton` is overloaded,<br>
GHC cannot infer a type.<br>
<br>
The TrieMap type is quite complicated as it allows different<br>
representations of (finite) Maps within it. There are three different<br>
internal maps you can use (the three pre-defined instances of the Map<br>
class - Data.Map, WrappedIntMap and AList) - I&#39;d go for Data.Map as it<br>
will be faster than AList and I think you are using Char for key so<br>
you can&#39;t use an IntMap.<br>
<br>
I don&#39;t have the package `list-tries` installed but I&#39;d guess at one<br>
of these two for the concrete type signature.<br>
<br>
Assuming you have imported Data.Map as<br>
<br>
import qualified Data.Map as Map<br>
<br>
(Probably this...)<br>
a :: TrieMap Map.Map [Char] Int<br>
<br>
<br>
(Possibly this...)<br>
a :: TrieMap (Map.Map Char Int) [Char] Int<br>
</blockquote></div><br></div></div>



_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic