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
= for 0 ( 100) (+ 1) $ \i - do
-- do something with i
print i
-
On Tue, Mar 9, 2010 at 16:25, zaxis z_a...@163.com wrote:
In FP the variable can not be changed once created. Yes, it has much
advantage . However, i feel it is too strict
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!
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 slow
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:
import Data.List
`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 wrote:
.
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
combination [1..20]
will wait for a long time ...
Hm, really?
Prelude :set
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..n] } in f
--
View
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 of
these beginner-level questions to the list, and I figured that
haskell-beginners
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] - [[a]]
:t (=) .f
(=) .f
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:
Okay, I
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 - a
:t (=) . f
(=) . f ::
, but I got No instance error.
-nwn
On Sat, Mar 27, 2010 at 9:20 AM, zaxis z_a...@163.com wrote:
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
= 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
ivan.miljeno...@gmail.com wrote:
zaxis z_a...@163.com writes:
In 6.10.4_1 under freebsd
let f x y z = x + y + z
*Money :t
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 z_a...@163.com writes:
Why do you bother with the interior definition of f
, or something else?
--Dietrich
On 2010 March 27, at 4:28, zaxis wrote:
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 z_a
:
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 hammer
does not make screwdriver unimportant.
While you can say that you can use
at 3:31 PM, zaxis z_a...@163.com wrote:
I just start ghci from shell and do nothing else. In fact, i really donot
know `Monad ((-) a) ` . Would you mind expplain it ?
Yusaku Hashimoto wrote:
Did you import the module includes the instance of Monad ((-) e)
somewhere in your code loaded
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
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!
-
fac
a where
typeOf :: Proxy a - TypeRep
-- uses ScopedTypeVariables extension
lookup :: forall a. Typeable a = TypeMap - Maybe a
lookup (TypeMap mp) = liftM (fromJust . fromDynamic) $ Map.lookup
(typeOf (Proxy :: Proxy a)) mp
-- ryan
On Tue, Apr 27, 2010 at 5:17 PM, zaxis z_a...@163.com
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
%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.
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 z_a...@163.com wrote:
%pacman -Q|grep xmonad
xmonad 0.9.1-4
xmonad-contrib 0.9.1-2
%%xmonad --recompile
Error detected while loading xmonad
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 z_a...@163.com wrote:
There is no any complain by ghc-pkg.
%ghc-pkg field xmonad
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 z_a...@163.com wrote:
%rm ~/.xmonad/xmonad.{hi,o}
%ls ~/.xmonad
history xmonad-i386-linux* xmonad.errors xmonad.hs
%xmonad --recompile
Error detected
#xmonad and xmond mailinglist later!
Ivan Lazar Miljenovic wrote:
zaxis z_a...@163.com 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 such the xmonad mailing list
`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!
%ghc-pkg list|grep
/usr/ports/devel/hs-ghc-pathssudo 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
for GHC installation directories
CABAL_SETUP=Setup.hs
.if defined(SLAVE)
GHC_CMD=ghc
.endif
.include ${.CURDIR}/../../lang/ghc/bsd.cabal.mk
.include bsd.port.mk
Ivan Miljenovic wrote:
Which version of GHC, which version of Cabal, and what is the Makefile?
zaxis z_a...@163.com
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-pathssudo make install clean
=== hs-ghc-paths-0.1.0.5_1 depends on executable: ghc - found
=== Configuring for hs-ghc-paths
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)
Sincerely!
n) hitNum
++ [\n]
zaxis z_a...@163.com writes:
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
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 work
checking all the seemingly related packages on hackage is
also an option (and still practical for sufficiently narrow
categories).
Hoogle:
http://haskell.org/hoogle/?hoogle=Text.Regex
Hayoo!:
http://holumbus.fh-wedel.de/hayoo/hayoo.html
Thomas
On Fri, Oct 16, 2009 at 9:17 PM, 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 `[()]'
In a
.
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 AM, zaxis z_a...@163.com wrote:
winSSQ count noRed noBlue = do {
yesRed - [1..33] \\ noRed;
yesBlue - [1..16] \\ noBlue
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
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 = [1..16] \\ noBlue;
bracket (openFile ssqNum.txt
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
the cat.
On Thu, Oct 22, 2009 at 01:02, zaxis z_a...@163.com wrote:
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
thank you! In fact i really donot understand unsafePerformIO very much !
Thomas DuBuisson wrote:
zaxis z_a...@163.com wrote:
let aaa = unsafePerformIO $ newIORef []
writeIORef aaa [1,2,3]
readIORef aaa
[(),(),()]
What in Haskells name do you think you're doing? Don't use
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:
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's the best
way
?
re-write aaa is not permitted.
it's the only way
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 z_a...@163.com writes:
value - readIORef aaa
writeIORef aaa (f value)
then aaa
replace k v xs = (k,v) : filter ((/=v) . fst) xs
Great ! thanks you very much
minh thu wrote:
2009/10/22 zaxis z_a...@163.com:
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
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 $
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_ssq_red = withFile ssqHitNum.txt ReadMode
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 within
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 to
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 (*)
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 z_a...@163.com wrote:
data Branch tok st a = forall b. Branch (PermParser tok st (b - a))
(GenParser tok st b)
I have
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);
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
valRef - liftIO $ newIORef val
%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
I have subscribed to xmonad maillist but i never received any email !
Deniz Dogan-3 wrote:
2009/11/16 zaxis z_a...@163.com:
%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
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)` ?
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,
Typeable)
#endif
In `X (ReaderT XConf (StateT
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:
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
info - fmap Just (io $ newTVarIO Map.empty)
let ?debugInfo = info
run
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 mind
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
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, 2009 at 16:59, zaxis z_a...@163.com wrote:
findHelper (x:xs) = do -- not lazy, but that's
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
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 fast
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/
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 = foldr
`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 -)
dateStr
%ghc --version
The Glorious
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`:
thanks!
Ivan Lazar Miljenovic wrote:
zaxis z_a...@163.com 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_day nextDay nDay
The correct syntax
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
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;
-- ...;
}
However, i donot know how to write pure function using C style
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 z_a...@163.com wrote:
thanks for all suggestions
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 ?
Is it a
Then can i change it to :
case timeout of
Just str - do
[(t, _)] - reads str
addTimeout t (hPutStrLn stderr *** TIMEOUT _exit 1)
return ()
_ - return ()
Sincerely!
Brandon S. Allbery KF8NH wrote:
On Feb 27, 2010, at 04:07 , zaxis wrote
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 zaxis:
Then can i change it to :
case
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
ls
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.
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 message in context:
http
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
2009/8/31 zaxis z_a...@163.com:
addDays 150
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': it =
thanks!
Luke Palmer-2 wrote:
On Mon, Aug 31, 2009 at 9:47 PM, zaxisz_a...@163.com wrote:
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
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
: the haskellwiki page on existential types.
2009/9/2 zaxis z_a...@163.com:
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
seems a bit understanding, i still need to think it for a while
thanks!
jkff wrote:
2009/9/2 zaxis z_a...@163.com:
Isnot it clear without the 'forall' ?
data Branch tok st a = Branch (PermParser tok st (b - a)) (GenParser tok
st
b)
thanks!
The situation is not so simple
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
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 z_a...@163.com, Haskell Cafe haskell-cafe@haskell.org
Cc:
From: Alexander Dunlap alexander.dun...@gmail.com
Date: Fri, 4 Sep 2009 18:14:50
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:
, 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
myFoldl f z xs = foldr step id xs z
where step x g a = g (f a x)
I
89 matches
Mail list logo