[Haskell-cafe] Why does ghci recompile the module compiled in different OS ?

2010-09-03 Thread zaxis
Both linux and freebsd has the same .ghci file. >cat ~/.ghci :def hoogle \str -> return $ ":! hoogle --count=15 \"" ++ str ++ "\"" :cd /media/G/www/qachina/db/doc/money the money.hs has many functions i need to use. On freebsd, i use the following command to compile it: >ghc -c -O2 money.hs >

Re: [Haskell-cafe] After `readFile`, why cannot i `writeFile` ?

2010-06-07 Thread zaxis
itNum.txt" $ unwords $ [no] ++ map (\n -> show n) hitNum > ++ ["\n"] > > zaxis writes: > >> hitSSQ :: String -> [Int] -> IO () >> hitSSQ no hitNum = do >>let newNum = unwords $ [no] ++ map (\n -> show n) hitNum >>hitN

[Haskell-cafe] After `readFile`, why cannot i `writeFile` ?

2010-06-07 Thread zaxis
hitSSQ :: String -> [Int] -> IO () hitSSQ no hitNum = do let newNum = unwords $ [no] ++ map (\n -> show n) hitNum hitNums <- fmap lines $ readFile "test.txt" writeFile "test.txt" $ unlines $ hitNums ++ [newNum] *** Exception: test.txt: openFile: resource busy (file is locked) Sincer

Re: [Haskell-cafe] How to fix this problem in FreeBSD ?

2010-05-30 Thread zaxis
I have to use openbox instead of xmonad now. As a reward , i can `make config` in any ports using openbox. (xmonad canot) zaxis wrote: > > /usr/ports/devel/hs-ghc-paths>sudo make install clean > ===> hs-ghc-paths-0.1.0.5_1 depends on executable: ghc - found > ===> C

Re: [Haskell-cafe] How to fix this problem in FreeBSD ?

2010-05-29 Thread zaxis
g for GHC installation directories CABAL_SETUP=Setup.hs .if defined(SLAVE) GHC_CMD=ghc .endif .include "${.CURDIR}/../../lang/ghc/bsd.cabal.mk" .include Ivan Miljenovic wrote: > > Which version of GHC, which version of Cabal, and what is the Makefile? > > zaxis

[Haskell-cafe] How to fix this problem in FreeBSD ?

2010-05-28 Thread zaxis
/usr/ports/devel/hs-ghc-paths>sudo make install clean ===> hs-ghc-paths-0.1.0.5_1 depends on executable: ghc - found ===> Configuring for hs-ghc-paths-0.1.0.5_1 [1 of 1] Compiling Main ( Setup.hs, Setup.o ) Setup.hs:18:22: Not in scope: `preMakefile' *** Error code 1 Stop in /usr/

Re: [Haskell-cafe] Why cannot ghc find a existng module ?

2010-05-11 Thread zaxis
`ghc-pkg list` finds two random packages. After `ghc-pkg unregsiter` the one installed by cabal in ~/.ghc/, all works normally now! %ghc-pkg list|grep -i random random-1.0.0.2 zaxis wrote: > > I have reinstall ghc, xmonad and xmonad-contrib but it still doesnot work! > > %

Re: [Haskell-cafe] Why cannot ghc find a existng module ?

2010-05-10 Thread zaxis
#xmonad and xmond mailinglist later! Ivan Lazar Miljenovic wrote: > > zaxis writes: > >> It seems that it is not a xmonad problem as xmond just call ghc >> directly. > > Well, yes, except that it might be something else to do with your > config, etc. and as s

Re: [Haskell-cafe] Why cannot ghc find a existng module ?

2010-05-09 Thread zaxis
you either go on #xmonad and ask the people there, or send > an email to the xmonad mailing list with your config attached. > > On 10 May 2010 15:37, zaxis wrote: >> >> %rm ~/.xmonad/xmonad.{hi,o} >> %ls ~/.xmonad >> history  xmonad-i386-linux*  xmonad.error

Re: [Haskell-cafe] Why cannot ghc find a existng module ?

2010-05-09 Thread zaxis
o see a list of the files searched for. Please check the file for errors. Ivan Lazar Miljenovic wrote: > > (Note that this really should be on the xmonad mailing list, but > anyway...). > > On 10 May 2010 15:09, zaxis wrote: >> >> There is no any complain by ghc-pkg.

Re: [Haskell-cafe] Why cannot ghc find a existng module ?

2010-05-09 Thread zaxis
eing used the same one that was used to build > xmonad-contrib? > > What does "ghc-pkg field xmonad-contrib exposed-modules | grep > LayoutHints" say? > > On 10 May 2010 14:59, zaxis wrote: >> >> %pacman -Q|grep xmonad >> xmonad 0.9.1-4 >> xmonad-

[Haskell-cafe] Why cannot ghc find a existng module ?

2010-05-09 Thread zaxis
%pacman -Q|grep xmonad xmonad 0.9.1-4 xmonad-contrib 0.9.1-2 %%xmonad --recompile Error detected while loading xmonad configuration file: /home/sw2wolf/.xmonad/xmonad.hs xmonad.hs:20:7: Could not find module `XMonad.Layout.LayoutHints': Use -v to see a list of the files searched for.

Re: [Haskell-cafe] Haskell and scripting

2010-05-03 Thread zaxis
xmonad is my favorite WM. BTW, why canot i receive any email from its mailinglist (i have subscribed from http://www.haskell.org/mailman/listinfo/xmonad)? minh thu wrote: > > Hi, > > You can take the xmonad approach: the configuration file is written in > Haskell and compiled, so no need for a

Re: [Haskell-cafe] A newbie question ?

2010-04-27 Thread zaxis
) = liftM (fromJust . fromDynamic) $ Map.lookup > (typeOf (Proxy :: Proxy a)) mp > > -- ryan > > On Tue, Apr 27, 2010 at 5:17 PM, zaxis wrote: >> >> newtype TypeMap = TypeMap (Map.Map TypeRep Dynamic) >> >> lookup :: Typeable a => TypeMap -> Maybe a >

[Haskell-cafe] A newbie question ?

2010-04-27 Thread zaxis
newtype TypeMap = TypeMap (Map.Map TypeRep Dynamic) lookup :: Typeable a => TypeMap -> Maybe a lookup (TypeMap mp) = res where res = liftM (fromJust . fromDynamic) $ Map.lookup (typeOf $ fromJust res) mp It seems that the `res` in `fromJust res` has not been defined ? Sincerely! - fa

[Haskell-cafe] what does the '~' mean ?

2010-04-15 Thread zaxis
instance (BinaryDefer a, BinaryDefer b) => BinaryDefer (a,b) where put (a,b) = put2 a b get = get2 (,) size x = let ~(a,b) = x in size a + size b putFixed (a,b) = putFixed2 a b getFixed = getFixed2 (,) in `size` function, what does the `~` mean ? Sincerely! - fac n

Re: [Haskell-cafe] Why is it so different between 6.12.1 and 6.10.4_1 ?

2010-03-27 Thread zaxis
gt; f (m a) a > > Note `(>>=)` propagates `a` into both of its arguments. That's why the > functions read same argument. > > HTH > -nwn > > On Sat, Mar 27, 2010 at 3:31 PM, zaxis wrote: >> >> I just start ghci from shell and do nothing else. In fact, i

Re: [Haskell-cafe] Why is it so different between 6.12.1 and 6.10.4_1 ?

2010-03-27 Thread zaxis
f python. Maciej Piechotka wrote: > > On Sat, 2010-03-27 at 04:28 -0700, zaxis wrote: >> Of course, you are wrong ! C is VERY important for almost every >> programmer >> in the world! > > > Hmm. We don't deny that C is important. However importance of hamm

Re: [Haskell-cafe] Why is it so different between 6.12.1 and 6.10.4_1 ?

2010-03-27 Thread zaxis
gramming with Haskell, so I am not sure what you mean > when you ask why Haskell supports C style. Are you talking about > mutable state, syntax, or something else? > > --Dietrich > > On 2010 March 27, at 4:28, zaxis wrote: > >> >> Of course, you are wrong !

Re: [Haskell-cafe] Why is it so different between 6.12.1 and 6.10.4_1 ?

2010-03-27 Thread zaxis
Of course, you are wrong ! C is VERY important for almost every programmer in the world! Why cannot C programmer use haskell ? And Why does haskell support C code style ? Ivan Miljenovic wrote: > > zaxis writes: > >>>>Why do you bother with the interior def

Re: [Haskell-cafe] Why is it so different between 6.12.1 and 6.10.4_1 ?

2010-03-26 Thread zaxis
erior definition of f in there? >> >> fac = product . enumFromTo 1 > > let fac = do is_zero <- (==0); if is_zero then return 1 else liftM2 > (*) id (fac . pred) > > -nwn > > On Sat, Mar 27, 2010 at 9:59 AM, Ivan Lazar Miljenovic > wrote: >> zaxis writes:

Re: [Haskell-cafe] Why is it so different between 6.12.1 and 6.10.4_1 ?

2010-03-26 Thread zaxis
tried this on a fresh ghci 6.12, but I got "No instance" error. > > -nwn > > On Sat, Mar 27, 2010 at 9:20 AM, zaxis wrote: >> >> In 6.12.1 under archlinux >>>let f x y z = x + y + z >>> :t f >> f :: (Num a) => a -> a -> a

[Haskell-cafe] Why is it so different between 6.12.1 and 6.10.4_1 ?

2010-03-26 Thread zaxis
In 6.12.1 under archlinux >let f x y z = x + y + z > :t f f :: (Num a) => a -> a -> a -> a > :t (>>=) . f (>>=) . f :: (Num a) => a -> ((a -> a) -> a -> b) -> a -> b > ((>>=) . f) 1 (\f x -> f x) 2 5 In 6.10.4_1 under freebsd > let f x y z = x + y + z *Money> :t f f :: (Num a) => a -> a -> a ->

Re: Re[Haskell-cafe] mote invocations in Haskell?

2010-03-23 Thread zaxis
Maybe erlang is more suitable for you as rpc is built in function in erlang. Yves Parès wrote: > > Okay, well, apparently I have to rely on an external HTTP server. This is > not very simple, is there another more suitable way to get RPC working in > haskell? > > > Yves Parès wrote: >> >> Ok

Re: [Haskell-cafe] Why does `flip` cause function type so different ?

2010-03-20 Thread zaxis
As a beginner, i cannot understand completely what both Maciej Piechotka and Daniel Fischer-4 said. However, i think it will be a big step for me to study haskell once i understand it. thanks ! zaxis wrote: > >>let f x xs = [x:xs,xs] >> :t f > f :: a -> [a] ->

Re: Re: [Haskell-cafe] Why does `flip` cause function type so different ?

2010-03-20 Thread zaxis
haskell-cafe . The goal of >> haskell-beginners is to encourage answers that are tailored to >> beginners, i.e. no scary existential multi-parameter category theory >> type class monads there. :) > > Well, yes; except that recently zaxis has been asking quite a few

[Haskell-cafe] Why does `flip` cause function type so different ?

2010-03-18 Thread zaxis
>let f x xs = [x:xs,xs] > :t f f :: a -> [a] -> [[a]] >:t (>>=) .f (>>=) .f :: a -> ([[a]] -> [a] -> b) -> [a] -> b > :t (flip (>>=) .f) (flip (>>=) .f) :: a -> [[a]] -> [[a]] Why is the type of `(>>=) .f` and `flip (>>=) .f` so different ? Sincerely! - fac n = let { f = foldr (*) 1 [1

Re: [Haskell-cafe] How to improve its performance ?

2010-03-18 Thread zaxis
] ^CInterrupted. Daniel Fischer-4 wrote: > > Am Donnerstag 18 März 2010 04:29:53 schrieb zaxis: >> The time is wasted to run combination even if use `combination (x:xs) = >> concat [(x:ys), ys] | ys <- combination xs] ' instead. >> in ghci >> >> >combi

Re: [Haskell-cafe] How to improve its performance ?

2010-03-17 Thread zaxis
`allPairs list = [(x,y) | x <- list, y <- list] ` is not what `combination` does ! >let allPairs list = [(x,y) | x <- list, y <- list] >allPairs [1,2,3] [(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3)] >combination [1,2,3] [[1,2,3],[2,3],[1,3],[3],[1,2],[2],[1],[]] Alexander Solla-2 wr

Re: [Haskell-cafe] How to improve its performance ?

2010-03-17 Thread zaxis
The time is wasted to run combination even if use `combination (x:xs) = concat [(x:ys), ys] | ys <- combination xs] ' instead. in ghci >combination [1..20] will wait for a long time ... Daniel Fischer-4 wrote: > > Am Donnerstag 18 März 2010 00:53:28 schrieb zaxis: &g

[Haskell-cafe] How to improve its performance ?

2010-03-17 Thread zaxis
import Data.List combination :: [a] -> [[a]] combination [] = [[]] combination (x:xs) = (map (x:) (combination xs) )++ (combination xs) samp = [1..100] allTwoGroup = [(x, samp\\x) | x <- combination samp] The above code is used to calculate all the two groups from sample data ? It is very slo

[Haskell-cafe] Are there any web server framework ?

2010-03-16 Thread zaxis
Erlang has yaws (http://yaws.hyber.org/) Scala has lift (http://liftweb.net/) Python has django (http://www.djangoproject.com/) Ruby has rails (http://rubyonrails.org/) How about haskell ? Is there any similar framework, which should be steady, powerful and easy to use, in haskell ? Sincerely!

Re: [Haskell-cafe] If the local variable can be changed ...

2010-03-09 Thread zaxis
tart where > loop x = if test x > then body x >> loop (step x) > else return () > > main = for 0 (< 100) (+ 1) $ \i -> do > -- do something with i > print i > - > > On Tue, Mar 9, 2010 at 16:

[Haskell-cafe] If the local variable can be changed ...

2010-03-09 Thread zaxis
In FP the variable can not be changed once created. Yes, it has much advantage . However, i feel it is too strict. As we know, the local variable is allocated on stack which is thread safe. So if the local variable can be changed, then we can use loop, etc. same as imperative languages. For exa

Re: [Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread zaxis
thanks! case timeout of Just str -> case reads str of [(t,_)] -> addtimeout (hPutStrLn stderr "*** TIMEOUT" >> _exit 1) _ -> return () _ -> return () is VERY clear! Daniel Fischer-4 wrote: > > Am Sonntag 28 Februar 2010 02:08:18 schrieb

Re: [Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread zaxis
> On Feb 27, 2010, at 04:07 , zaxis wrote: >> >> xxxMain = do >>timeout <- getEnv "xxx_TIMEOUT" >>case timeout of >>Just str | [(t, _)] <- reads str -> do >>addTimeout t (hPutStrLn stderr "*** TIMEOUT" >>

[Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread zaxis
xxxMain = do timeout <- getEnv "xxx_TIMEOUT" case timeout of Just str | [(t, _)] <- reads str -> do addTimeout t (hPutStrLn stderr "*** TIMEOUT" >> _exit 1) return () _ -> return () ... What does the `|` mean in "Just str | [(t, _)] <- reads str

Re: [Haskell-cafe] About code style ?

2010-02-02 Thread zaxis
fac n = let { f = foldr (*) 1 [1..n] } in f VERY interesting :) Jinjing Wang wrote: > > fac n = let { > f = foldr (*) 1 [1..n] > } in f > > :D > > sorry for double reply, need to cc cafe, this is fun. > > On Tue, Feb 2, 2010 at 4:33 PM, zaxis wrote: &g

Re: [Haskell-cafe] About code style ?

2010-02-02 Thread zaxis
thanks for all suggestions. zaxis wrote: > > For me i like C style instead of layout. For example, > func1 a = do > -- ... > a * 2 > -- ... > > I always write it as: > func1 a = do { > -- ...; >a * 2; > -- ...; > } > > How

[Haskell-cafe] About code style ?

2010-02-01 Thread zaxis
For me i like C style instead of layout. For example, func1 a = do -- ... a * 2 -- ... I always write it as: func1 a = do { -- ...; a * 2; -- ...; } However, i donot know how to write pure function using C style. func1 a = { -- ...; a * 2; -- ...; } will not compil

Re: [Haskell-cafe] Why cannot i add the `let` declaration ?

2010-01-30 Thread zaxis
thanks! Ivan Lazar Miljenovic wrote: > > zaxis writes: >> find_the_day sDay 0 = sDay >> find_the_day sDay nDay = >> let nextDay = addDays 1 sDay >> if (is_trade_day $ nextDay) >> then find_the_day nextDay (nDay - 1) >> else find_the_d

[Haskell-cafe] Why cannot i add the `let` declaration ?

2010-01-29 Thread zaxis
find_the_day sDay 0 = sDay find_the_day sDay nDay = if (is_trade_day $ nextDay sDay) then find_the_day (nextDay sDay) (nDay - 1) else find_the_day (nextDay sDay) nDay nextDay sDay = addDays 1 sDay The above code works fine. But the following always reports `compiling error`: find_t

Re: [Haskell-cafe] Could not find module `Text.Regex'

2010-01-29 Thread zaxis
`cabal install regex-compat` fixes my problem. thanks! Lee Houghton-3 wrote: > > On 29/01/2010 03:51, zaxis wrote: >> >> import Text.Regex >> >> date_by_ntday dateStr ntday = do >> let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex

[Haskell-cafe] Could not find module `Text.Regex'

2010-01-28 Thread zaxis
import Text.Regex date_by_ntday dateStr ntday = do let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") dateStr %ghc --version The Glorious Glasgow Haskell Compilation System, version 6.12.1 Which package(s) do i need to use Text.Regex ? Sincerely! - fac n = fold

[Haskell-cafe] xmonad cannot find its library after upgrading GHC

2010-01-17 Thread zaxis
After `pacman -Syu`, the ghc is upgraded to 6.12.1 %ghc --version The Glorious Glasgow Haskell Compilation System, version 6.12.1 However, the xmonad still stay as it is: %pacman -Q|grep -i xmonad xmonad 0.9-2.1 xmonad-contrib 0.9-1.2 %pacman -Ql xmonad|more .. xmonad /usr/lib/ghc-6.10.4/ x

Re: [Haskell-cafe] darcs 2.4 beta 1 release

2010-01-07 Thread zaxis
Both darcs and xmonad are only great product i know! thanks! Reinier Lamers-2 wrote: > > Hi all, > > The darcs team would like to announce the immediate availability of darcs > 2.4 > beta 1. darcs 2.4 will contain many improvements and bugfixes compared to > darcs 2.3.1. Highlights are the fa

[Haskell-cafe] How can i set the seed random number generator ?

2009-12-21 Thread zaxis
In erlang, first i use the following function to set the seed: new_seed() -> {_,_,X} = erlang:now(), {H,M,S} = time(), H1 = H * X rem 32767, M1 = M * X rem 32767, S1 = S * X rem 32767, put(random_seed, {H1,M1,S1}). then use random:uniform/1 to get the random number. In ha

Re: [Haskell-cafe] How to understand such a `case` ?

2009-12-08 Thread zaxis
en return $ Just $ file x >else if filex' >then return $ Just $ file' x >else findHelper xs > > > The specific syntax being used is called a "pattern guard": > http://www.haskell.org/haskellwiki/Pattern_guard > > On Tue, Dec 8, 2

[Haskell-cafe] How to understand such a `case` ?

2009-12-08 Thread zaxis
findHelper (x:xs) = do -- not lazy, but that's not really important here filex <- fileExists (file x) filex' <- fileExists (file' x) case () of _ | filex -> return $ Just $ file x | filex'-> return $ Just $ file' x

[Haskell-cafe] I really donot know how to use `newtype` ?

2009-11-27 Thread zaxis
import Control.Monad.State import Control.Monad.Reader data XConf = XConf {} data XState = XState {} newtype X a = X (ReaderT XConf (StateT XState IO) a) > :t StateT StateT :: (s -> m (a, s)) -> StateT s m a > :t ReaderT ReaderT :: (r -> m a) -> ReaderT r m a then how to use `X` ? Would you

Re: [Haskell-cafe] Where is `newTVarIO` defined ?

2009-11-24 Thread zaxis
thanks! Maybe the hoogle shoud add it Ross Mellgren wrote: > > Control.Concurrent.STM > > On Nov 24, 2009, at 6:11 PM, zaxis wrote: > >> >> I cannot hoogle it. It appears in Pugs: >> >> run' ("-d":rest) = do >&g

[Haskell-cafe] Where is `newTVarIO` defined ?

2009-11-24 Thread zaxis
I cannot hoogle it. It appears in Pugs: run' ("-d":rest) = do info <- fmap Just (io $ newTVarIO Map.empty) let ?debugInfo = info run' rest Sincerely! - fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/Where-is-%60newTVarIO%60-d

Re: [Haskell-cafe] How to understand such a newtype ?

2009-11-21 Thread zaxis
thanks ! Felipe Lessa wrote: > > On Sat, Nov 21, 2009 at 06:20:40PM -0800, zaxis wrote: >> newtype X a = X (ReaderT XConf (StateT XState IO) a) >> #ifndef __HADDOCK__ >> deriving (Functor, Monad, MonadIO, MonadState XState, MonadReader >> XConf, >> Type

[Haskell-cafe] How to understand such a newtype ?

2009-11-21 Thread zaxis
newtype X a = X (ReaderT XConf (StateT XState IO) a) #ifndef __HADDOCK__ deriving (Functor, Monad, MonadIO, MonadState XState, MonadReader XConf, Typeable) #endif In `X (ReaderT XConf (StateT XState IO) a)`, X is a type constructor, how to understand `(ReaderT XConf (StateT XState IO) a)` ?

Re: [Haskell-cafe] About xmonad

2009-11-16 Thread zaxis
I have subscribed to xmonad maillist but i never received any email ! Deniz Dogan-3 wrote: > > 2009/11/16 zaxis : >> >> %uname -a >> Linux myarch 2.6.31-ARCH #1 SMP PREEMPT Tue Nov 10 19:48:17 CET 2009 i686 >> AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ Authen

[Haskell-cafe] About xmonad

2009-11-15 Thread zaxis
%uname -a Linux myarch 2.6.31-ARCH #1 SMP PREEMPT Tue Nov 10 19:48:17 CET 2009 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ AuthenticAMD GNU/Linux %xmonad --version xmonad 0.9 In firefox, the `save as` dialog doesnot appear when i want to choose picture to save by right clicking the mouse

Re: [Haskell-cafe] Why can `env` be assigned value two times ?

2009-11-15 Thread zaxis
thanks for all your answers ! zaxis wrote: > > defineVar :: Env -> (Id, Val) -> IOThrowsError Val > defineVar envRef (id, val) = do { > env <- liftIO $ readIORef envRef; > env <- return $ filter (\(_id, _) -> _id/=id) env; -- clear the > current scope

[Haskell-cafe] Why can `env` be assigned value two times ?

2009-11-14 Thread zaxis
defineVar :: Env -> (Id, Val) -> IOThrowsError Val defineVar envRef (id, val) = do { env <- liftIO $ readIORef envRef; env <- return $ filter (\(_id, _) -> _id/=id) env; -- clear the current scope valRef <- liftIO $ newIORef val; liftIO $ writeIORef envRef $ ((id, valRef):env);

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-11 Thread zaxis
Without `forall`, the ghci will complain: "Not in scope: type variable `b' " It is clear now. thank you! Dan Piponi-2 wrote: > > On Wed, Nov 11, 2009 at 4:24 PM, zaxis wrote: >> data Branch tok st a     = forall b. Branch (PermParser tok st (b -> a)) >&g

[Haskell-cafe] What does the `forall` mean ?

2009-11-11 Thread zaxis
import Text.ParserCombinators.Parsec data PermParser tok st a = Perm (Maybe a) [Branch tok st a] data Branch tok st a = forall b. Branch (PermParser tok st (b -> a)) (GenParser tok st b) I have hoogled the `forall` but i cannot find any appropriate answer! thanks! - fac n = foldr (*)

Re: [Haskell-cafe] ANNOUNCE: xmonad 0.9 is now available!

2009-10-26 Thread zaxis
xmonad is great WM i have ever seen. I have used it for a long time. However, i donot know whether or not it is a *good* combination to use xmonad and lxpanel together insead of dzen . Don Stewart-2 wrote: > > >http://xmonad.org > > The xmonad dev team is pleased t

[Haskell-cafe] Hoogle is great but ...

2009-10-25 Thread zaxis
http://www.haskell.org/hoogle/ is VERY great for haskeller. However, i feel hoogle should be improved by providing more examples as : isInfixOf :: Eq a => [a] -> [a] -> Bool The isInfixOf function takes two lists and returns True iff the first list is contained, wholly and intact, anywhere withi

Re: [Haskell-cafe] Lazy problem ?

2009-10-23 Thread zaxis
good_ssq_red:: IO [Int] good_ssq_red =do { samp <- fmap str2Ints $ readFile "ssqHitNum.txt"; return $ statis samp; } It works now ! thank you Bulat Ziganshin-2 wrote: > > Hello zaxis, > > Friday, October 23, 2009, 11:15:01 AM, you wrote: > >> good

[Haskell-cafe] Lazy problem ?

2009-10-23 Thread zaxis
"ssqHitNum.txt" contains data as below: 6 7 18 24 30 32 9 4 12 20 25 28 29 16 3 5 11 12 31 32 11 2 9 13 15 19 24 3 5 17 21 25 27 32 14 5 9 15 21 26 31 13 12 16 25 26 27 31 05 ... good_ssq_red:: IO [Int] good_ssq_red = withFile "ssqHitNum.txt" ReadMode (\h -> do { samp <- fmap str2Ints $ h

Re: [Haskell-cafe] How can i safely change the value of specified key ?

2009-10-22 Thread zaxis
>>replace k v xs = (k,v) : filter ((/=v) . fst) xs Great ! thanks you very much minh thu wrote: > > 2009/10/22 zaxis : >> >>>>f xs = (2,) : filter ((/=2) . fst) xs >> It works but not general as `f` still needs to change other value >> accordin

Re: [Haskell-cafe] How can i safely change the value of specified key ?

2009-10-22 Thread zaxis
>>f xs = (2,) : filter ((/=2) . fst) xs It works but not general as `f` still needs to change other value according to the "KEY". Maybe Data.List will supply what i need. Ketil Malde-5 wrote: > > zaxis writes: > >>>>value <- readIORef aaa >

Re: [Haskell-cafe] How can i safely change the value of specified key ?

2009-10-22 Thread zaxis
n `f` ? Bulat Ziganshin-2 wrote: > > Hello zaxis, > > Thursday, October 22, 2009, 11:28:14 AM, you wrote: > >> aaa <- newIORef ([]::[(Int,Int)]) >> writeIORef aaa [(1,1),(2,2),(3,3)] > >> then if i want to change aaa to [(1,1),(2,222),(3,3)] , what&#x

[Haskell-cafe] How can i safely change the value of specified key ?

2009-10-22 Thread zaxis
aaa <- newIORef ([]::[(Int,Int)]) writeIORef aaa [(1,1),(2,2),(3,3)] then if i want to change aaa to [(1,1),(2,222),(3,3)] , what's the best way ? re-write aaa is not permitted. Sincerely! -- View this message in context: http://www.nabble.com/How-can-i-safely-change-the-value-of-specified-k

Re: [Haskell-cafe] why cannot i get the value of a IORef variable ?

2009-10-21 Thread zaxis
thank you! In fact i really donot understand "unsafePerformIO" very much ! Thomas DuBuisson wrote: > > zaxis wrote: >>> let aaa = unsafePerformIO $ newIORef [] >>> writeIORef aaa [1,2,3] >>> readIORef aaa >> [(),(),()] > > What

Re: [Haskell-cafe] why cannot i get the value of a IORef variable ?

2009-10-21 Thread zaxis
t]) > > -R. Kyle Murphy > -- > Curiosity was framed, Ignorance killed the cat. > > > On Thu, Oct 22, 2009 at 01:02, zaxis wrote: > >> >> > let aaa = unsafePerformIO $ newIORef [] >> > writeIORef aaa [1,2,3] >> > readIORef aaa >> [()

[Haskell-cafe] why cannot i get the value of a IORef variable ?

2009-10-21 Thread zaxis
> let aaa = unsafePerformIO $ newIORef [] > writeIORef aaa [1,2,3] > readIORef aaa [(),(),()] sincerely! -- View this message in context: http://www.nabble.com/why-cannot-i-get-the-value-of-a-IORef-variable---tp26004111p26004111.html Sent from the Haskell - Haskell-Cafe mailing list archive at

Re: [Haskell-cafe] How to use "bracket" properly ?

2009-10-19 Thread zaxis
oh! thanks! But why ? Heinrich Apfelmus wrote: > > zaxis wrote: >> It works very well. However, as i am used to C style so i want convert it >> into >> >> winSSQ count noRed noBlue = do { >> let yesRed = [1..33] \\ noRed; >> let yesBlue = [

Re: [Haskell-cafe] How to use "bracket" properly ?

2009-10-18 Thread zaxis
The original code is: winSSQ count noRed noBlue = do let yesRed = [1..33] \\ noRed let yesBlue = [1..16] \\ noBlue bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1) It works very well. However, as i am used to C style so i want convert it

Re: [Haskell-cafe] How to use "bracket" properly ?

2009-10-18 Thread zaxis
y effect on what Monad you're in, so the whole thing > can be in IO. > > Note that when you do x <- [1..3]; y <- [4..6] you're going to get all > 9 pairs of values from x and y, by the way. > > Hope this helps, > Dan > > On Mon, Oct 19, 2009 at 1:33 A

[Haskell-cafe] How to use "bracket" properly ?

2009-10-18 Thread zaxis
winSSQ count noRed noBlue = do { yesRed <- [1..33] \\ noRed; yesBlue <- [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); return () } will report: Couldn't match expected type `IO ()' against inferred type `[()]'

Re: [Haskell-cafe] There is no Text.Regex module

2009-10-16 Thread zaxis
ayoo/hayoo.html > > Thomas > > > On Fri, Oct 16, 2009 at 9:17 PM, zaxis wrote: >> >> In Archlinux i can use Text.Regex as below: >> import Text.Regex >> let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") dateStr >> >> Howe

[Haskell-cafe] There is no Text.Regex module

2009-10-16 Thread zaxis
In Archlinux i can use Text.Regex as below: import Text.Regex let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") dateStr However, in Ubuntu 9.10 it doesnot work reporting no Text.Regex module. So i download and install regex-base and regex-posix from Hackage. But it still doesnot wo

Re: [Haskell-cafe] Would you mind explain such a code ?

2009-09-10 Thread zaxis
rameters, the 1st is list element and the 2nd is a funtion whose initial value is id). myFoldl f z xs = foldr step id xs z where step x g a = g (f a x) staafmeister wrote: > > > > zaxis wrote: >> >> myFoldl :: (a -> b -> a) -> a -> [b] -> a >>

[Haskell-cafe] Would you mind explain such a code ?

2009-09-09 Thread zaxis
myFoldl :: (a -> b -> a) -> a -> [b] -> a myFoldl f z xs = foldr step id xs z where step x g a = g (f a x) I know myFoldl implements foldl using foldr. However i really donot know how it can do it ? Please shed a light one me, thanks! -- View this message in context: http://www.nabble.com

Re: [Haskell-cafe] How to preload the module of my own

2009-09-04 Thread zaxis
if this module loads other modules, > you may need to play with ':cd' in addition to ':load'. > > hope this helps, > matthias > > > On Fri, Sep 04, 2009 at 06:14:50PM -0700, Alexander Dunlap wrote: >> To: zaxis , Haskell Cafe >> Cc: >> From:

[Haskell-cafe] How to preload the module of my own

2009-09-04 Thread zaxis
I want to preload the module automatically when starting ghci. The module located in ~/work directory contains some functions i use everyday. Now i use an alias: alias ghci='ghci -i ~/money/Money.hs' which works fine. However i feel there maybe are more elegant way. thanks! -- View this messa

Re: [Haskell-cafe] How to understand the 'forall' ?

2009-09-02 Thread zaxis
seems a bit understanding, i still need to think it for a while thanks! jkff wrote: > > 2009/9/2 zaxis : >> >> Isnot it clear without the 'forall' ? >> data Branch tok st a = Branch (PermParser tok st (b -> a)) (GenParser tok >> st >> b) >

Re: [Haskell-cafe] How to understand the 'forall' ?

2009-09-01 Thread zaxis
in 'b -> a' in the first argument of Branch is the same > as the 'b' in 'GenParser tok st b'. > > See also: the haskellwiki page on existential types. > > 2009/9/2 zaxis : >> >> data Branch tok st a = forall b. Branch (PermParser

[Haskell-cafe] How to understand the 'forall' ?

2009-09-01 Thread zaxis
data Branch tok st a = forall b. Branch (PermParser tok st (b -> a)) (GenParser tok st b) please shed a light on me, thanks! -- View this message in context: http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.html Sent from the Haskell - Haskell-Cafe mailing list arc

Re: [Haskell-cafe] How to fix such a TYPE problem ?

2009-08-31 Thread zaxis
thanks! Luke Palmer-2 wrote: > > On Mon, Aug 31, 2009 at 9:47 PM, zaxis wrote: >> >>>let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") >> "2009-08-31" >>>fromGregorian y m d >> >> Couldn't match expect

[Haskell-cafe] How to fix such a TYPE problem ?

2009-08-31 Thread zaxis
>let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") "2009-08-31" >fromGregorian y m d Couldn't match expected type `Integer' against inferred type `Int' In the first argument of `fromGregorian', namely `y' In the expression: fromGregorian y m d In the definition of `it':

Re: [Haskell-cafe] Data.Time is so weak ?!

2009-08-31 Thread zaxis
toWeekDate meets my need, thank you! Colin Adams-3 wrote: > > How about: > > import Data.Time.Calendar > import Data.Time.Calendar.WeekDate > > main = do > let (y, w, d) = toWeekDate $ addDays 150 (fromGregorian 2009 8 31) > putStrLn $ show d > > >

Re: [Haskell-cafe] Data.Time is so weak ?!

2009-08-30 Thread zaxis
addDays 150 (fromGregorian 2009 8 31) will work. However, how can i get its weekday from the result ? thanks! zaxis wrote: > > today = fromGregorian 2009 8 31 > > then how to calculate the day passing 150 days ? > > today + 150 doesnot work ! > -- View this mess

[Haskell-cafe] Data.Time is so weak ?!

2009-08-30 Thread zaxis
today = fromGregorian 2009 8 31 then how to calculate the day passing 150 days ? today + 150 doesnot work ! -- View this message in context: http://www.nabble.com/Data.Time-is-so-weak--%21-tp25218462p25218462.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. __