Hugh Perkins wrote:
> Is reflection hard in Haskell? In C# its easy, and its one of the most
> powerful features of C#
That's another way of saying that the truly powerful features are
missing from C#...
> Yes, but I'm kindof stuck giving useful input to makeConstrM, so if
> anyone has any idea
Hugh Perkins wrote:
> Hi,
>
> Trying to write a function to deserialize a haskell type from xml.
>
> deserializeXml :: Data(a) => String -> a
That type signature describes a function that can deliver *anything*
(that is in class Data), whatever you ask from it. From your
description (also the o
Roberto Zunino wrote:
> Floating out (newBuffer defaultSize) as in
>
> | foo = newBuffer defaultSize
> |
> | toLazyByteString m = S.LPS $ inlinePerformIO $ do
> | buf <- foo
> | return (runBuilder (m `append` flush) (const []) buf)
>
> would still be safe, AFAICS. Floating out buf instead
Greetings,
I was trying to understand the magic inside Data.Binary, and found two
somewhat suspicious uses of inlinePerformIO, which imho has a far too
innocuous name:
| toLazyByteString :: Builder -> L.ByteString
| toLazyByteString m = S.LPS $ inlinePerformIO $ do
| buf <- newBuffer defaultS
Grzegorz wrote:
> > mkdir libmaxent
> > cd libmaxent
> > ar x /usr/local/lib/libmaxent.a
> > cd ..
> > ghci (...) libmaxent/*.o
>
> This doesn't quite work:
> ghc-6.6.1: libmaxent/trainer.o: unknown symbol `_ZNSt8ios_base4InitC1Ev'
> final link ... ghc-6.6.1: linking extra libraries/objects fail
Andrew Coppin wrote:
> Note that the challenge asks for the "internal" bitmap representation of
> an IEEE double-precision integer
Actually it didn't. It asked for the machine's internal representation
of a double precision float, and you are not guaranteed that this
representation conforms to I
Eric wrote:
> (1) Have Handlers implement a method handle(m: Msg). To add new types of
> message, we declare message types which extend Msg. The Handler then
> uses runtime type testing to decide how to deal with each message. The
> advantage of this design is that we can add new Handler and new
Albert Y. C. Lai wrote:
> I say Excel is a functional language. If there needs to be the quoted
> distinction, fine: Excel the language is a functional language, and
> Excel the application is an interpreter of said language.
Excel has functions, but does it treat functions as it treats other
da
Bryan O'Sullivan wrote:
> Udo Stenzel wrote:
>
> >There is another bug of this sort in your code. Consider
> >
> >>incWordCount w m = M.insertWith (+) w 1 m
> >
> >There is no reason to evaluate the sum inside the map, instead an
> >
Pete Kazmier wrote:
> train:: [B.ByteString] -> WordFreq
> train words = frequencyMap
> where
> frequencyMap = foldr incWordCount M.empty words
> incWordCount w m = M.insertWith (+) w 1 m
>
> So is 'incWordCount' strict in its second argument? I'm still not
> sure ex
kynn wrote:
> (I don't need elegant
> factorial or Fibonacci functions in my everyday work.)
I think you do. Most of your utility programs probably fit into the
simple frame of
main = interact $ unlines . map f . lines
for suitable f. Of course, f is hardly ever the factorial function, but
it
Sergey Perminov wrote:
> I wished to get output of unix commands in haskell code.
>
> So i wrote:
> --
> import System.IO
> import System.Process
>
> eval :: String -> IO String
> eval s = do (_,hOutput,_,hProcess) <-
Leandro Penz wrote:
> buildStuff =
> func1 ++ func2 ++ func3 ++ func4
>
> My idea is to have a monad with a concatenating >>, so that I can:
>
> bulidStuff = do
> func1
> func2
> func3
> func4
buildStuff = concat [
func1,
func2,
func3,
func4 ]
Remember,
Alex Queiroz wrote:
>
> I don't quite get how ($!) works. I have this function:
>
> ids <- liftM (map fromSql . concat ) $! quickQuery con query []
There's a difference between an IO action and the result of said action,
and similarly there's a difference between making sure an action is
e
Neil Mitchell wrote:
> As others have said though, I wouldn't worry overly about it. The
> whole concept of static linking being wrong, but dynamic linking being
> fine, when you can flip between the modes just by changing compiler,
> is just silly. You don't infringe (or uninfringe) copyright with
Benjamin Franksen wrote:
> Udo Stenzel wrote:
> > Sure, you're right, everything flowing in the same direction is usually
> > nicer, and in central Europe, that order is from the left to the right.
> > What a shame that the Haskell gods chose to give the arguments to
J. Garrett Morris wrote:
> On 2/4/07, Udo Stenzel <[EMAIL PROTECTED]> wrote:
> >> exists s wmap = isJust $ Map.lookup (sort s) wmap >>= find (== s) . snd
>
> If you're going to write it all on one line, I prefer to keep things
> going the same direction:
C.M.Brown wrote:
> I've found that:
>
> let (answer2, remainder) = parseAnswer (force answer)
>
> where
>
> force :: Eq a => a -> a
> force x = if x==x then x else x
>
> Seems to do the trick.
...but I'd advise against using it. If the power fails at the right
time, you're left with no file
J. Garrett Morris wrote:
> Maybe has a Monad instance, so you can write this as follows (untested):
>
> exists str wmap = boolFromMaybe exists'
>where exists' =
> do x <- Map.lookup (sort str) wmap
> find (== str) (snd x)
> boolFromMaybe (Just _) = True
>
John Ky wrote:
> On 1/25/07, BBrraannddoonn SS.. AAllllbbeerryy
> KKFF88NNHH <[EMAIL PROTECTED]> wrote:
> I'm probably missing something, but:
>
> (a) Why not:
>
> data ANode = Branch { name :: String, description :: String,
> children :: [AnyNode] }
>
Marco Túlio Gontijo e Silva wrote:
> is there a way to defined something as a map to use in tuples? I tried
> this:
>
> mapTuple f (a, b) = (f a, f b)
>
> But the type inferred to it is not as generic as I wanted:
>
> mapTuple :: (t -> t1) -> (t, t) -> (t1, t1)
What you seem to want to do is im
Ross Paterson wrote:
> This (like StateT) gives you strictness in the pair, but doesn't give
> the strictness in the state that the original poster wanted.
I think the OP wanted both. If State is lazy in the pair, a long chain
of the form (a >>= (b >>= (c >>= ... >>= z))) gets build up and blows
Yitzchak Gale wrote:
> You're right, it is not in the docs. I don't think anyone would
> have planned it that way. StateT is strict only because there
> happens to be a line in a do-expression that looks like:
> (a, s') <- runStateT m s
> The tuple pattern-match causes the strictness.
Yitzchak Gale wrote:
> Here is a concrete example:
>
> Let's say you want to shuffle a large list randomly,
> within a larger application that lives inside some
> MTL monad stack. Among other things, your monad
> m satisfies (RandomGen g, MonadState g m), perhaps
> after a lift.
>
> Well, it turn
Yitzchak Gale wrote:
> It seems to me that a natural notion of a state transformer
> in the ST monad is the type:
>
> STRef s st -> ST s a
Are there any useful functions of this type? I guess, your intention is
that this "transformer" makes no other use of the ST monad than reading
or writing a
[EMAIL PROTECTED] wrote:
> I'm timing the following script.I'm not expert to evaluate th O'ness
> of this code, I hope someone can do it. The program clusters n
> integers in m buckets based on their distance. Anyway I thing should
> be linear.So I timed som executions changing the first arg.
> [
Steve Schafer wrote:
> Here's the essence of the problem. If I have this:
>
> process1 x y =
>let u = foo x y;
>v = bar u;
>w = baz v
>in w
>
> I can easily rewrite it in point-free style:
>
> process1 = baz . bar . foo
That should have been
process1 = (.) (baz . b
Reto Kramer wrote:
> What I'm really looking for is not so much the chaining of StateT
> compositions, but rather the isolation of StateA from StateB while
> they both flow from the search loop into the respective library calls
> (foo, bar) transparently to the application programmer.
How ab
Alfonso Acosta wrote:
> On 12/13/06, Udo Stenzel <[EMAIL PROTECTED]> wrote:
> >Finished! Look Ma, no existentials, no Typeable, no wrappers, even the
> >types have become simple!
>
> I like the fact that type parameters are removed, which makes them
> homegeneus and
Alfonso Acosta wrote:
> If anyone finds a way of implementing something equivalent to this code
> without unsafeCoerce# and ...
>
> * Not changing chooseDesc or finding an equivalent
> * Not splitting or changing Descriptor type (I already found an
> equivalent way which uses existentials and i
Alfonso Acosta wrote:
> I've been using Data.Dynamic but the Typeable requirement doesn't go
> well with FFI declarations (which don't accept type contexts).
You wouldn't need a Typeable context anyway; what's biting you is that
Dynamic is not one of the primitive types that can pass across the FF
TJ wrote:
> --
> module Global where
>
> import Data.IORef
>
> theGlobalVariable = newIORef []
>
> testIt = do ref <- theGlobalVariable
>original <- readIORef ref
>print original
>writeIORef ref [1,2,3]
>
Dougal Stanton wrote:
> Is there some sort of equivalent of the if/then/else construct for use
> in the IO monad? For instance the following can get quite tedious:
>
> > do bool <- doesFileExist filename
> >if bool
> >then sth
> >else sth'
>
> Is there a more compact way of writing th
[EMAIL PROTECTED] wrote:
> >> (lo, hi) <- getBounds buf
> >
> > to
> >
> > let (lo,hi) = bounds buf
>
> The interface changed between GHC 6.4.2 and 6.6.
> But no honorable Haskell paladin would ever dare to use UndeadArrays.
Hm, and 'bounds' is simply gone? Hope that doesn't
Niko Korhonen wrote:
> I have the following code whose purpose is to add dither (noise) to a given
> array. The code looks very straightforward but apparently it has a memory leak
> somewhere.
No, it doesn't. It can't, because it doesn't even compile. After
correcting the obvious
> (lo,
Donald Bruce Stewart wrote:
> So how do we help out the beginners, other than warning about fromJust,
> and providing a useful error message as we can, for when they just go
> ahead and use head anyway?
Kill head and tail right now and provide a safe equivalent? Either
uncons :: [a] -> Maybe (
jim burton wrote:
> I want to split a string into 5 parts of equal length, with the last fifth
> padded if necessary, but can't get it right - here's what I've got -
fifths s = unwords.take 5.unfoldr (Just . splitAt l) $ s ++ repeat ' '
where l = (length s + 4) `div` 5
Of course no Haskeller
Andrea Rossato wrote:
> Now, the state will not be entirely consumed/evaluated by the user,
> and so it will not become garbage. Am I right?
No. The state cannot become garbage, because there is still a reference
to it. As long as runStateT has not returned, any part of the state can
still be ac
Andrea Rossato wrote:
> I did not get an appreciable improvement with performGC, as you can
> see from here:
> http://gorgias.mine.nu/haskell/a.out.withPerformGC.ps
>
> But I found a solution: just write the opml state component to a file!
Obviously the values in question were not garbage, rather
Vraj Mohan wrote:
> my_sqrt :: Float -> Float
> my_sqrt x = improve 1 x
> where improve y x = if abs (y * y - x) < epsilon
> then y
> else improve ((y + (x/y))/ 2) x
>epsilon = 0.1
>
>
>
> This works f
Robert Dockins wrote:
> FWIW, I'm using Apple's Mail.app, and it doesn't have a "reply-to-
> list". In fact, I don't know of a mail client off the top of my head
> that does
Mutt does. But that's to be expected, considering that it was written
because the author was fed up with the poor handling
Mikael Johansson wrote:
> On Tue, 10 Oct 2006, Misha Aizatulin wrote:
> > Here is an argument against Reply-To munging. I'd say I agree with it:
> >
> >http://www.unicom.com/pw/reply-to-harmful.html
> * It provides no benefit to the user of a reasonable mailer.
> [...]
> 1) get multiple copies of
Yang wrote:
> type Poly = [(Int,Int)]
>
> addPoly1 :: Poly -> Poly -> Poly
> addPoly1 p1@(p1h@(p1c,p1d):p1t) p2@(p2h@(p2c,p2d):p2t)
>| p1d == p2d = (p1c + p2c, p1d) : addPoly1 p1t p2t
>| p1d < p2d = p1h : addPoly1 p1t p2
>| p1d > p2d = p2h : addPoly1 p1 p2t
> addPoly1 p1 [] = p1
> addP
Matthias Fischmann wrote:
> although this wasn't the original problem, i like it, too :). but now
> i am stuck in finding an optimal implementation for lines.
Isn't the obvious one good enough?
lines [] = []
lines s = go s
where
go [] = [[]]
go ('\n':s) = [] : lines s
go (c:s) = le
Ketil Malde wrote:
> Daniel Fischer <[EMAIL PROTECTED]> writes:
>
> > Maybe I've misused the word segfault.
>
> I think so. A segfault is the operating-system complaining about an
> illegal memory access. If you get them from Haskell, it is likely a
> bug in the compiler or run-time system (or
Lemmih wrote:
> main = do
>args <- getArgs
>flip mapM_ args $ \arg ->
> flip mapM_ [1..3] $ \n ->
>putStrLn $ show n ++ ") " ++ arg
Or even:
main = do
args <- getArgs
putStr $ unlines [ show n ++ ") " ++ arg
| arg <- args, n <- [1..3] ]
I'm real
Daniel Fischer wrote:
> > Most certainly not. I'm pretty sure this is to a bug in your code.
> > Something retains a data structure which is actually unneeded. Probably
>
> Apparently. And my money is on a load of lines from the file (of which I need
> only the first and last Char).
Then you'r
Daniel Fischer wrote:
> The programme consumed more and more memory (according to top),
> kswapd started to have a higher CPU-percentage than my programme,
> programme died, system yelling 'Speicherzugriffsfehler', top displays
> 'kswapd'.
> I believe that means my programme demanded more memory t
Andrea Rossato wrote:
> It seems related to dynamic linking: I created a separated module
> (Xml.hs) that imports Text.XML.HaXml and parses a xml string. I then
> created a file (xml.hs) that imports Xml and prints "name", defined in
> Xml.hs. The expected output should be "elementTest".
Whatever
Andrea Rossato wrote:
> [12:03:[EMAIL PROTECTED]:~/devel/haskell/xml]$ ghci -package HaXml xml1.hs
> [logo]
> Loading package base-1.0 ... linking ... done.
> Loading package haskell98-1.0 ... linking ... done.
> Loading package HaXml-1.13.1 ... linking ... done.
> Skipping Main ( xml1
Tamas K Papp wrote:
> Is there a way to use NaN and Infinity as literals, or at least to
> test if a value is NaN or Infinity?
>
> *Main> let nan=0/0
> *Main> nan
> NaN
> *Main> nan==0/0
> False
>
> so "storing" the value does not work...
Not sure what you mean here. In IEEE floating point, NaN
Stephane Bortzmeyer wrote:
> I'm trying to use Parsec for a language which have identifiers where
> the '-' character is allowed only inside identifiers, not at the start
> or the end.
>
> identifier = do
> start <- letter
> rest <- many (alphaNum <|> char '-')
> end <- letter
Bulat Ziganshin wrote:
> Data.HashTable may be a faster alternative for Map (if ordering isn't
> required)
Or it may not. Finding a good hash function for the words John is
counting, is a challenge itself. Finding a good one that doesn't look
at each character at least once, might be outright im
John Goerzen wrote:
> I have the below program, and I'm trying to run it on an input of about
> 90MB. It eats RAM like crazy, and I can't figure out why.
>
> wordfreq inp = Map.toList $ foldl' updatemap (Map.empty::Map.Map String Int)
> inp
> where updatemap nm word = Map.insertWith updatefu
Lennart Augustsson wrote:
> Well, bind is extracting an 'a'. I clearly see a '\ a -> ...'; it
> getting an 'a' so it can give that to g. Granted, the extraction is
> very convoluted, but it's there.
Oh, that can be remedied...
> m >>= g = m . flip g
In fact, why even mention m?
> (>>=) =
Benjamin Franksen wrote:
> Sure. Your definition of bind (>>=):
> ...
> applies f to something that it has extracted from m, via deconstructor
> unpack, namely a. Thus, your bind implementation must know how to produce
> an a from its first argument m.
I still have no idea what you're driving at,
Julien Oster wrote:
> While we're at it: The best thing I could come up for
>
> func2 f g l = filter f (map g l)
>
> is
>
> func2p f g = (filter f) . (map g)
>
> Which isn't exactly point-_free_. Is it possible to reduce that further?
Sure it is:
func2 f g l = filter f (map g l)
func2 f g = (
Chris Kuklewicz wrote:
> I just tried to mimic regular expression matching with ReadP and got what
> seems like a non-terminating program. Is there another way to use ReadP to
> do this?
>
> >-- Simulate "(a?|b+|c*)*d" regular expression
> >test = star (choice [quest (c 'a')
> >
Chris Kuklewicz wrote:
> Again, Parsec requires you to put "try" where you need it
I'm pretty sure it does, although this
> Udo Stenzel wrote:
> >countBetween 0 n p = p <:> countBetween 0 (n-1) p <|> return []
is a place where it's not needed in
Stephane Bortzmeyer wrote:
> Parsec provides "count n p" to run the parser p exactly n times. I'm
> looking for a combinator "countBetween m n p" which will run the
> parser between m and n times. It does not exist in Parsec.
infixr 2 <:>
(<:>) = ap . ap (return (:))
countBetween 0 0 _ = return [
Andrea Rossato wrote:
> Il Mon, Aug 28, 2006 at 09:28:02PM +0100, Brian Hulley ebbe a scrivere:
> > data Eval_SOI a = SOIE {runSOIE :: State -> (a, State, Output, Bool)}
>
> well, I thought that this was not possible:
> (>>=) :: m a -> (a -> m b) -> m b
And you are right. In case of an exception
[EMAIL PROTECTED] wrote:
> I found a way to remove this space leak, however, I do not really
> understand why there was a space leak in the first place. I would
> really appreciate any light that could be shed on this.
> instance ArrowChoice SF where
> left (SF f)
> = SF (\xs -> combine xs
Andrea Rossato wrote:
> this is what I'm trying to do, sort of: turn the code at the button
> into the do-notation.[1]
> type MSO a = State -> (a, State, Output)
>
> mkMSO :: a -> MSO a
> mkMSO a = \s -> (a, s, "")
>
> bindMSO :: MSO a -> (a -> MSO b) -> MSO b
> bindMSO m f = \x ->
>
Hi Gregory,
Gregory Wright wrote:
> step :: Tag s -> ST s (Maybe Integer)
> step t = do
> c <- readSTRef (count t)
> s <- readSTRef (state t)
> writeSTRef (count t) (c - 1)
> writeSTRef (state t) (nextState s)
> if (c <= 0) then return Nothing else return (J
Neil Mitchell wrote:
> I'm trying to write out a binary file, in particular I want the
> following functions:
>
> hPutInt :: Handle -> Int -> IO ()
>
> hGetInt :: Handle -> IO Int
>
> For the purposes of these functions, Int = 32 bits, and its got to
> roundtrip - Put then Get must be the same.
Szymon Z??bkiewicz wrote:
> The compiler tells me thats there's an error on line 10:
> "The last statement in a 'do' construct must be an expression"
I think, you have reached the point where treating do-notation as magic
won't help you. Remember,
> do
> nr1 <- read (prompt "enter 1. number
Marc Weber wrote:
> I've tried as an exercise to learn how to use the state monad to create
> a tree this way:
>
> createTree :: Int -> Int -> (Tree Int, Int)
> createTree 4 = runState $ State $ \s -> (Node s [] , s+1) -- stop at level 4
> createTree level = runState (do item <- State $ (\s -> (s,
Ahn, Ki Yung wrote:
> Recently, I'm facing the dark side of laziness
> -- the memory leak because of laziness.
>
> Are there standardized approaches for detecting and fixing
> these kind of problems?
Not really. As Don S. already said, try heap profiling. The function
that is too lazy will show
Matthias Fischmann wrote:
> And it's really not as easy to control as you suggest: If you ever
> take in a single patch under the GPL,
This kind of thing doesn't happen by accident. Patches don't magically
creep into your code, you have to apply them deliberately and you should
always know whethe
Matthias Fischmann wrote:
> But if GPL is stuck to any part of the code and
> manages to infect the rest, the client can make you sign as many NDAs
> as there can be. The GPL still entitles you to sell it.
Nonsense. The GPL says, *if* you distribute a binary, *then* you also
have to distribute t
Martin Percossi wrote:
> Paul Hudak wrote:
> >foo x y = ...
> >
> >We know that x and y are formal parameters, whereas if they were
> >capitalized we'd know that they were constructors.
>
> I agree that naming can be abused. But I think it should be *me* ...
Oh, you like to decide lexical ambigu
Jason Dagit wrote:
> On 8/4/06, Donn Cave <[EMAIL PROTECTED]> wrote:
> >6. Instability - available for 15 years, you say, but does the Haskell
> >of 15 years ago support today's programs? Does standard Haskell
> >even support today's programs?
Uh, this one's wrong. Does C++ of 15 years
Hans van Thiel wrote:
> I'm wondering why I can't find any commercial Haskell applications on
> the Internet. Is there any reason for this?
Of course. Corporations are conservative to the point of being
boneheaded. So to avoid risk, they all went on the internet and said,
"Gee, I can't find any
Gabriel Sztorc wrote:
> I want to filter a list with a predicate that returns a IO value,
> something that filterM is supposed to do. The problem is, filterM
> overflows the stack for really big lists
Are you sure it's filterM's fault? Can you post the code in question?
Stack overflows are usua
Stephane Bortzmeyer wrote:
> > The first would be to test whether "bb" is followed by "eof" or
> > "comma" before accepting it.
>
> notFollowedBy actually does the opposite (checking that there are no
> more letters).
Are you sure that you don't actually want
*> many1 letter `sepBy1` comma
? J
Stephane Bortzmeyer wrote:
> minilang = do
>char 'a'
>try (optional (do {comma ; char 'b'}))
>optional (do {comma ; char 'c'})
>eof
>return "OK"
>
> * CUT HERE ***
>
> parse error at (line 1, column 2):
> unexpected "c"
> expecting "
Andrew Pimlott wrote:
> On Thu, Jul 27, 2006 at 09:59:37PM +0200, Udo Stenzel wrote:
> > In fact, that's consistent with the current documentation, because
> >
> > *> getFileName "foo" == "foo"
> > *> getFileName "foo/" == "
Andrew Pimlott wrote:
> On Wed, Jul 26, 2006 at 05:06:41PM -0400, David Roundy wrote:
> > This doesn't apply uniformly to all programs--except that we can say
> > that any path with a trailing '/' is intended to be a directory, and
> > if it's not, then that's an error.
>
> I thought some more abo
Neil Mitchell wrote:
> How about
>
> class FilePathLike a where
>getRealFilePath :: a -> String
>
> Then convert readFile etc. to take a FilePathLike, rather than a filepath?
Uhm, just a minute ago the argument was that we can't change the IO
library... Anyway, my gut says, it dislikes 'cla
Duncan Coutts wrote:
> In practise in the short term, the choice is between each application
> fumbling with strings in different incorrect ways or a library that
> fumbles with strings in a rather more considered and portable way.
Honestly I don't see a reason to bother with (++) and takeWhile an
Andrew Pimlott wrote:
> Maybe the trailing slash is important enough to take into account.
No, not the trailing slash. The difference between a directory and its
contents is important enough. This is ususally encoded using a trailing
slash, but I'd rather not worry about that detail in a program
Duncan Coutts wrote:
> On Wed, 2006-07-26 at 15:29 +0200, Udo Stenzel wrote:
>
> > Exactly. I believe, a FilePath should be an algebraic datatype.
>
> We've had this discussion before. The main problem is that all the
> current IO functions (readFile, etc) use the File
Andrew Pimlott wrote:
> > The drive functions stand on their own as a chunk, and are possibly
> > not well suited to a Posix system, but are critical for a Windows
> > system.
>
> Why are they critical for portable code? I am fine with
> Windows-specific functions, but I think it's a mistake to b
Chad Scherrer wrote:
> But why should this...
>
> >sumArrays [] = error "Can't apply sumArrays to an empty list"
> >sumArrays (x:xs) = runSTArray (result x)
> >where
> >result x = do x0 <- thaw x
> > mapM_ (x0 +=) xs
> > return x0
>
> work differently tha
Johan Grönqvist wrote:
> I would like use a list (as stack) that can contain several kinds of values.
>
> data Element = Int Int | Float Float | Func : Machine -> Machine | ...
>
> Now I would like to have this type be an instance of the class Show, so
> that I can see what the stack contains i
Neil Mitchell wrote:
> Or if you don't want to go for a fold next, in a style more similar to
> the original:
>
> maximum [] = undefined
> maximum [x] = x
> maximum (a:b:xs) = maximum (max a b : xs)
It even reproduces the stack overflow, though for a different reason.
Better write it this way:
m
Bjorn Lisper wrote:
> - your definition of fromInteger will behave strangely with the elementwise
> extended operations, like (+). 1 + [[1,2],[3,4]] will become
> [[2,2],[3,5]] rather than [[2,3],[4,5]]. Array languages supporting this
> kind of overloading invariably have the second form of
Vladimir Portnykh wrote:
> I am trying to define the following types
>
> data MyStringType a = String deriving (Eq, Ord, Show)
> data QADouble a = Double deriving (Eq, Ord, Show)
These are not what you think they are. MyStringType has a phantom type
parameter and only one value, which is the con
[EMAIL PROTECTED] wrote:
> apparently - Clean has better handling of strictness
> issues [saying at the same time that he/she doesn't use Clean...]
Uhm... well... and does it? From what I've heard, Clean has the same
mechanism as Haskell, which is the 'seq' primitive. Clean just adds
some syntac
Bjorn Lisper wrote:
> Here is one way to do it. First, you have to interpret operations on
> matrices as being elementwise applied. E.g, (*) is interpreted as zipWith
> (zipWith (*)) rather than matrix multiply
What's this, the principle of greatest surprise at work? Nonono, (*)
should be matrix
Jenny678 wrote:
> Can somebody help me
> My Problem is to define a code for:
>
> >cross 7 -- means 7*7
> >+++
> >++ ++
> >+ + + +
> >+++
> >+ + + +
> >++ ++
> >+++
As always, try to decompose a hard problem into simple steps. It's
probably adequate to repr
minh thu wrote:
> but i consider to move back to c/c++.
I'm led to believe that you just haven't got the hang of the things that
just aren't there in C, such as Monads and higher order functions. So
you cannot yet see what you would miss in C. (And I guess, you're not
feeling at home in C++ eith
[EMAIL PROTECTED] wrote:
> I need a functions which takes as argument a list of lists like this one:
>
> [[1,2],[3],[4]]
>
> and gives me a list of list with all the possible combinations like this one:
>
> [[1,3,4],[2,3,4]]
sequence
Finding out why it is named that strangely is left as an exc
Jacques Carette wrote:
> Bulat Ziganshin wrote:
>
> >malloc :: Storable a => IO (Ptr a)
> >malloc = doMalloc undefined
> > where
> > doMalloc :: Storable b => b -> IO (Ptr b)
> > doMalloc dummy = mallocBytes (sizeOf dummy)
> >
> >
> Is there any reason to not code this as
>
> malloc
Jason Dagit wrote:
> > reserved "units." <|> reserved "unit."
>
> I always struggle with when I need to use 'try' with parsec.
>
> My understanding is that if 'unit.' appears in the input the first
> parser will parse up to the '.' and then fail and consume the input up
> to that point, leaving
Evan Martin wrote:
> Here's the beginning of
> the file, where it's not obvious to me how to distinguish elements in
> the "::" section from the rest of the file.
> :: Judge: USDP Game: dip Variant: standard
> :: Deadline: F1901M Mon 20 Feb 2006 20:00 PST
> :: URL: http://www.diplom.org/dpjudg
Evan Martin wrote:
> Unfortunately, the output is intended to be human-readable, and this
> makes parsing it a bit of a pain. Here are some sample lines from its
> output:
>
> France: Army Marseilles SUPPORT Army Paris -> Burgundy.
> Russia: Fleet St Petersburg (south coast) -> Gulf of Bothnia.
>
Eugene Crosser wrote:
> Anyway, I understand that you used 'seq' in your example as a way to
> "strictify" the function that updates accumulator. Could you (or
> anyone) explain (in plain English, preferably:) the reason why 'seq' is
> the way it is. In the first place, why does it have the first
Eugene Crosser wrote:
> Having read "Yet another Haskell tutorial" (note on p.20), doesn't foldl
> have to read the complete list before it can start processing it
> (beginning from the last element)? As opposed to foldr that can fetch
> elements one by one as they are needed?
Both foldl and fold
Eugene Crosser wrote:
> This is my program:
>
> module Main where
> import Data.Map
> main = printMax . (foldr processLine empty) . lines =<< getContents
> processLine line map = insertWith (\new old -> new + old) line 1 map
> printMax map = putStrLn $ show $ foldWithKey
>(\key val acc
1 - 100 of 150 matches
Mail list logo