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
>
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
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
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
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
/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/
`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!
>
> %
#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
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
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.
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-
%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.
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
) = 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
>
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
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
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
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
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 !
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
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:
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
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 ->
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
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] ->
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
>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
]
^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
`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
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
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
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!
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:
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
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
> 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" >>
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
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
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
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
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
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
`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
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
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
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
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
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
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
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
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
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
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
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)` ?
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
%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
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
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);
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
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 (*)
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
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
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
"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
>>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
>>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
>
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
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
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
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
>> [()
> 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
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 = [
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
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
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 `[()]'
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
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
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
>>
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
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:
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
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)
>
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
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
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
>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':
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
>
>
>
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
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.
__
89 matches
Mail list logo