Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Fwd: Implementing a spellchecker - problem with
Data.HashTable performance (umptious)
2. Embed haskell (Rosario Borda )
3. state monad (Paul Higham)
4. Re: state monad (Lorenzo Bolla)
----------------------------------------------------------------------
Message: 1
Date: Sat, 21 Apr 2012 17:16:03 +0100
From: umptious <[email protected]>
Subject: Re: [Haskell-beginners] Fwd: Implementing a spellchecker -
problem with Data.HashTable performance
To: [email protected]
Message-ID:
<CAE20bNu3RCnC=g0og_byjkm_i7f74dh-zvk0fqkb4rviz9b...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
On 20 April 2012 17:58, Lorenzo Bolla <[email protected]> wrote:
> Maybe you could also time with datasets of increasing size (up to 1M),
> and see if the execution time grows like O(n^2), in which case I'd say
> it's a hashing problem...
>
Testing with 1/4 and 1/2 the original data is definitely an excellent thing
to do.
Also, In the original post it sounded as if **with the same data set**
1 - creating the hash with the data already in memory is fast
2 - reading the data is fast
3 - doing both is very, very slow
..but was this true? Or was the in-memory data set different? If it was
different, then HOW was it different?
Other thought: you printed the last line to force the reading of the set in
the file read test, ***but would this have forced the entire set to be
converted into ByteStrings***? Even more than that - I'm no Haskell expert,
but I can claim to have debugged a fair amount of weird code. Such
enormously long read times are more typical of IO or, possibly, GC
weirdness than any possible flaw in a hashing algorithm. In fact, it's
almost impossible to see how an algorithmic flaw could generate such a vast
runtime without provoking GC weirdness. And even then it would be pretty
amazing.
So I'd try reading in the strings and converting to byte strings and then
doing something simple to them that didn't involve hashing. Like xoring
every byte in a byte string and then the result of every string with every
other - some operation that definitely forces every bytestring to be
present in bytestring form for sure.
You might open a system monitor and watch memory consumption, too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120421/f66e49c2/attachment-0001.htm>
------------------------------
Message: 2
Date: Sun, 22 Apr 2012 08:17:24 +0200 (CEST)
From: "Rosario Borda " <[email protected]>
Subject: [Haskell-beginners] Embed haskell
To: beginners haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Hi All,
There is a simple method for embed haskell in other languages, like latex?
An example in quasiquotation notation:
\documentclass{article}
\title{Hello World}
\begin{document}
\maketitle
Hello world! and reversed: [haskell: putStrLn reverse "Hello, World!"]
\end{document}
Many thanks, :)
Rosario
------------------------------
Message: 3
Date: Sun, 22 Apr 2012 01:40:17 -0700
From: Paul Higham <[email protected]>
Subject: [Haskell-beginners] state monad
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; CHARSET=US-ASCII
I am trying to come to grips with the state monad and as a starting point I
copied the some code directly from the book Learn You a Haskell for Great Good
then added the type synonym for Stack
import Control.Monad.State
type Stack = [Int]
pop :: State Stack Int
pop = State $ \(x:xs) -> (x,xs)
push :: Int -> State Stack ()
push a = State $ \xs -> ((),a:xs)
However, attempting to load this into ghci produces the errors
stackPlay.hs:6:7: Not in scope: data constructor `State'
stackPlay.hs:9:10: Not in scope: data constructor `State'
Please excuse the cognitive deficit, but I cannot figure out why this should
not work as advertised.
::paul
------------------------------
Message: 4
Date: Sun, 22 Apr 2012 09:56:33 +0100
From: Lorenzo Bolla <[email protected]>
Subject: Re: [Haskell-beginners] state monad
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
I believe that the type constructor for State is now lowercase: "state"
not "State".
import Control.Monad.State
type Stack = [Int]
pop :: State Stack Int
pop = state $ \(x:xs) -> (x,xs)
push :: Int -> State Stack ()
push a = state $ \xs -> ((),a:xs)
play = do
push 1
push 2
push 3
pop
main = print $ runState play []
L.
On Sun, Apr 22, 2012 at 01:40:17AM -0700, Paul Higham wrote:
> I am trying to come to grips with the state monad and as a starting point I
> copied the some code directly from the book Learn You a Haskell for Great
> Good then added the type synonym for Stack
>
> import Control.Monad.State
>
> type Stack = [Int]
>
> pop :: State Stack Int
> pop = State $ \(x:xs) -> (x,xs)
>
> push :: Int -> State Stack ()
> push a = State $ \xs -> ((),a:xs)
>
>
> However, attempting to load this into ghci produces the errors
>
> stackPlay.hs:6:7: Not in scope: data constructor `State'
>
> stackPlay.hs:9:10: Not in scope: data constructor `State'
>
>
> Please excuse the cognitive deficit, but I cannot figure out why this should
> not work as advertised.
>
> ::paul
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
--
Lorenzo Bolla
http://lbolla.info
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120422/7a59f8f2/attachment-0001.pgp>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 46, Issue 39
*****************************************