Albert Y. C. Lai wrote:
Mitar wrote:
I am really missing the (general) split function built in standard
Haskell. I do not understand why there is something so specific as
words and lines but not a simple split? The same goes for join.
Don't forget Text.Regex.splitRegex.
Which is just:
Nicholls, Mark wrote:
Hello, I wonder if someone could answer the following…
The short question is what does @ mean in
mulNat a b
| a = b = mulNat' a b b
| otherwise = mulNat' b a a
where
mulNat' x@(S a) y orig
| x == one = y
This thread is obviously a source of much fun. I will play too.
Cristian Baboi wrote:
On Fri, 28 Dec 2007 18:32:05 +0200, Jules Bean [EMAIL PROTECTED]
wrote:
Cristian Baboi wrote:
Let me ask you 3 simple questions.
Can one use Haskell to make dynamically linked libraries (DLL on
Windows,
Lihn, Steve wrote:
Programmer with perl background would think split like:
list of string = split regex original string
Since regex is involved, it is specific to (Byte)String, not a generic
list. Also it appears one would need help from Text.Regex(.PCRE) to do
that.
intercalate a
Brian Sniffen wrote:
On Dec 28, 2007 6:05 AM, Andrew Coppin [EMAIL PROTECTED] wrote:
[I actually heard a number of people tell me that learning LISP would
change my life forever because LISP has something called macros. I
tried to learn it, and disliked it greatly. It's too messy. And what the
Jonathan Cast wrote:
So there is a program (or, rather, type) you can write with newtype that
can't be written with data:
newtype T = T T
That compiles, and anything of type T is ⊥. But it breaks my mental model of
what the compiler does for newtypes. I always think of them as differently
I have received patches which will help Cabal make ghc-6.6 and gc-6.8 friendly
regex-tdfa. The problem below is from a change in STUArray from 3 to 4
parameters going from 6.6 to 6.8. I think adding another '_' to each pattern
match makes it work for 6.8.
Once I get these patches working
Andre Nathan wrote:
Hello (Newbie question ahead :
I tried this for insertProc, but it obviously doesn't work... what would
be the correct way to do this?
insertProc :: Pid - StateT PsMap IO PsInfo
insertProc pid = do
proc - procInfo pid -- XXX this is obviously wrong...
psMap - get
Michael Vanier wrote:
I haven't been following this thread closely, but would it be rude to
suggest that someone who doesn't want to put the effort into learning
the (admittedly difficult) concepts that Haskell embodies shouldn't be
using the language?
Sorry Michael, but I will take your
Jules Bean wrote:
ChrisK wrote:
A safer gimmick...
Ben Franksen wrote:
tickWhileDoing :: String - IO a - IO a
tickWhileDoing msg act = do
hPutStr stderr msg hPutChar stderr ' ' hFlush stderr
start_time - getCPUTime
tickerId - forkIO ticker
... an async exception here will leave
Thomas Hartman wrote:
Is there some way to use any of the various regex packages on hackage
via yhc? Has anyone installed one them successfully?
I'd like regex-tdfa, but would settle for regex-posix, or really,
anything that brings the convenience of regex to yhc.
In general, is there a
Sterling Clover wrote:
Actually, I suspect GHC's strictness analyzer will give you reasonable
performance with even the naive version, but fancier ideas are at
http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog
If given an 'n' you are looking for the (2^x) such that 2^x = n
Reinier Lamers wrote:
ChrisK wrote:
For GHC 6.6 I created
foreign import ccall unsafe memcpy
memcpy :: MutableByteArray# RealWorld - MutableByteArray#
RealWorld - Int# - IO ()
{-# INLINE copySTU #-}
copySTU :: (Show i,Ix i,MArray (STUArray s) e (ST s)) = STUArray s i
e
Andrew Coppin wrote:
ChrisK wrote:
For GHC 6.6 I created
foreign import ccall unsafe memcpy
memcpy :: MutableByteArray# RealWorld - MutableByteArray#
RealWorld - Int# - IO ()
{-# INLINE copySTU #-}
copySTU :: (Show i,Ix i,MArray (STUArray s) e (ST s)) = STUArray s i
e
Andrew Coppin wrote:
Andrew Coppin wrote:
copy :: Word32 - IOUArray Word32 Bool - Word32 - IO (IOUArray
Word32 Bool)
copy p grid size = do
let size' = size * p
grid' - newArray (1,size') False
mapM_
(\n - do
b - readArray grid n
if b
then mapM_ (\x - writeArray
A safer gimmick...
Ben Franksen wrote:
tickWhileDoing :: String - IO a - IO a
tickWhileDoing msg act = do
hPutStr stderr msg hPutChar stderr ' ' hFlush stderr
start_time - getCPUTime
tickerId - forkIO ticker
... an async exception here will leave the ticker runnning
res -
Maurício wrote:
Hi,
After I have spawned a thread with
'forkIO', how can I check if that
thread work has finished already?
Or wait for it?
Thanks,
Maurício
The best way to do this is using Control.Exception.finally:
myFork :: IO () - IO (ThreadId,MVar ())
myFork todo =
m -
the standard way to do that is use an existential wrapper:
(This needs -fglasgow-exts or some flags)
module Main where
class Interface x where
withName :: x - String
data A = A String
instance Interface A where
withName (A string) = Interface A with ++ string ++
data B = B
Jason Dusek wrote:
ChrisK [EMAIL PROTECTED] wrote:
the standard way to do that is use an existential wrapper:
Does this relate to the basket of fruit problem in object
oriented languages?
You created the existential wrapper to allow a multimorphic
list type?
When you access
Greetings,
There are new version 0.82 and 0.93 of regex-posix. If you use regex-posix with
Data.ByteString then you should upgrade to obtain a fix for a crash error.
There are new version of regex-pcre available on hackage and the two darcs
repositories:
Thank you very much for the error report. I have tracked down the cause.
You are searching against an empty Bytestring. This is now represented by
-- | /O(1)/ The empty 'ByteString'
empty :: ByteString
empty = PS nullForeignPtr 0 0
And while the useAsCString and useAsCStringLen functions
Greetings,
There are new version 0.82 and 0.93 of regex-posix. If you use regex-posix with
Data.ByteString then you should upgrade to obtain a fix for a crash error.
There are new version of regex-pcre available on hackage and the two darcs
repositories:
John D. Ramsdell wrote:
On Nov 17, 2007 3:04 PM, apfelmus [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
Unfortunately, I don't have Paulson's book (or any other ML book :) at
home. I'm too lazy to figure out the specification from the source code,
I guess the code is too opaque,
The data dependency is circular. The case e of Str and Brk are not-circular:
layout examines the input parameters to determine column'. Then column'
is used to compute columnOut and s'. Then the current data is
prepended to s'. The Blo case is the circular one. Pushing the circular
' versus 'Main' prompt is a UI feature for experts, not
for new users. Making this more obvious or verbose or better documented does
not fix the lack of control the user feels.
The only flags that the user can easily find are those listed by --help:
chrisk$ ghci --help
Usage:
ghci
Dan Piponi wrote:
On Nov 13, 2007 1:24 PM, Ryan Ingram [EMAIL PROTECTED] wrote:
I tend to prefer where, but I think that guards function declarations are
more readable than giant if-thens and case constructs.
Up until yesterday I had presumed that guards only applied to
functions. But I
[EMAIL PROTECTED] has sent me a new bug report. Apparently he can crash
ghc-6.8.1 when compiling regex-tdfa-0.93 (darcs under
http://darcs.haskell.org/packages/regex-unstable/regex-tdfa/ ).
Should I open a ticket for this?
I darcs got the newest regex-tdfa (0.93 iirc) and made all the
Yeah, my code wants to open up the internals of Lazy bytestrings. Until
recently this was possible toChunks, but it would be best to rewrite it for the
newest Lazy representation (which comes with new shiny ghc 6.8.1).
It is a trivial change, but I due to ghc-6.8.1 failing on ppc G4 OS X, I
[EMAIL PROTECTED] has sent me a new bug report. Apparently he can crash
ghc-6.8.1 when compiling regex-tdfa-0.93 (darcs under
http://darcs.haskell.org/packages/regex-unstable/regex-tdfa/ ).
Should I open a ticket for this?
I darcs got the newest regex-tdfa (0.93 iirc) and made all the
Hi,
I wrote the regex-base API you are looking at.
Uwe Schmidt wrote:
Hi all,
what's the simplest way to check, whether a given string
is a wellformed regular expression?
import Text.Regex.Posix.String(compile)
or
import Text.Regex.Posix.ByteString(compile)
etc..
In the API there's
Hi Bryan,
I wrote the current regex API, so your suggestions are interesting to me. The
also goes for anyone else's regex API opinions, of course.
Bryan O'Sullivan wrote:
Ketil Malde wrote:
Python used to do pretty well here compared
to Haskell, with rather efficient hashes and text
karle wrote:
My declaration is as followed:-
type Address = Int
data Port = C | D deriving(Eq,Show)
data Payload = UP[Char] | RTDP(Address,Port) deriving(Eq,Show)
data Pkgtype = RTD | U deriving(Eq,Show)
type Pkg = (Pkgtype,Address,Payload)
type Table = [(Address,Port)]
I disagree with Simon Marlow here. In practice I think Claus' definition of
compatible is good enough:
Simon Marlow wrote:
Claus Reinke wrote:
- consider adding a new monad transformer to a monad transformer
library, or a new regex variant to a regex library - surely the new
package
Simon Marlow wrote:
Ultimately when things settle down
it might make sense to do this kind of thing, but right now I think an
easier approach is to just fix packages when dependencies change, and to
identify sets of mutually-compatible packages (we've talked about doing
this on Hackage
Don Stewart wrote:
stefanor:
On Mon, Oct 15, 2007 at 10:57:48PM +0100, Claus Reinke wrote:
so i wonder why everyone else claims to be happy with the status quo?
We aren't happy with the status quo. Rather, we know that no matter how
much we do, the situation will never improve, so most of us
Simon Marlow wrote:
Several good points have been raised in this thread, and while I might
not agree with everything, I think we can all agree on the goal: things
shouldn't break so often.
I have another concrete proposal to avoid things breaking so often. Let us
steal from something that
[EMAIL PROTECTED] wrote:
Peter Verswyvelen writes about non-monadic IO, unique external worlds:
But... isn't this what the Haskell compiler runtime do internally
when IO monads are executed? Passing the RealWorld singleton from
action to action?
In GHC, yes.
I never looked into any
Brandon S. Allbery KF8NH wrote:
On Oct 15, 2007, at 13:32 , Peter Verswyvelen wrote:
[EMAIL PROTECTED] wrote:
Yes, *different approach*. So, there *are* differences. Compilers,
anyway,
are special applications. I wanted to see - responding to Brandon - a
normal Haskell program, which
[EMAIL PROTECTED] wrote:
Yitzchak Gale writes:
Dan Piponi wrote:
The reusability of Num varies inversely with how many
assumptions you make about it.
A default implementation of pi would only increase usability,
not decrease it.
Suppose I believe you. (Actually, I am afraid, I have
Johan Tibell wrote:
On 10/9/07, David Benbennick [EMAIL PROTECTED] wrote:
On 10/9/07, Johan Tibell [EMAIL PROTECTED] wrote:
data Rope = Empty
| Leaf
| Node !Rope !Rope
The point is that Empty
can only appear at the top by construction
How about indicating this in your
Dan Weston wrote:
Ronald Guida wrote:
I need some help with space and time leaks.
I know of two types of space leak. The first type of leak occurs when
a function uses unnecessary stack or heap space.
GHCi sum [1..10^6]
*** Exception: stack overflow
Apparently, the default definition
Deborah Goldsmith wrote:
UTF-16 is the native encoding used for Cocoa, Java, ICU, and Carbon, and
is what appears in the APIs for all of them. UTF-16 is also what's
stored in the volume catalog on Mac disks. UTF-8 is only used in BSD
APIs for backward compatibility. It's also used in plain
Peter Verswyvelen wrote:
Paul L wrote:
We recently wrote a paper about the leak problem. The draft is at
http://www.cs.yale.edu/~hl293/download/leak.pdf. Comments are welcome!
I'm trying to understand the following in this paper:
(A) repeat x = x : repeat x
or, in lambdas:
(B) repeat =
I disagree -- see below
Dan Weston wrote:
I suggest that it be removed and the real Control.Monad.Fix.fix function
be defined in its own section, with an side-by-side comparison with a
named recursive function. This would be useful because the type
fix :: (a - a) - a
is highly
Philippa Cowderoy wrote:
On Mon, 17 Sep 2007, Adrian Hey wrote:
Ideally the way to deal with this is via standardised interfaces (using
type classes with Haskell), not standardised implementations. Even this
level of standardisation is not a trivial clear cut design exercise.
e.g we
Conor McBride wrote:
Hi folks
On 12 Sep 2007, at 00:38, Brent Yorgey wrote:
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote: Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
[..]
If for some reason you want a version that does return an error in
Dan Piponi wrote:
On 9/5/07, Ketil Malde [EMAIL PROTECTED] wrote:
On Wed, 2007-09-05 at 08:19 +0100, Simon Peyton-Jones wrote:
Error message from GHCi:
test/error.hs:2:8:
No instance for (Num String)
arising from use of `+' at test/error.hs:2:8-17
Possible fix:
Chris Smith wrote:
The following code builds and appears to work great (assuming one allows
undecidable instances). I have tried both a natural translation into
type synonym families, and also the mechanical transformation in
http://www.cse.unsw.edu.au/~chak/papers/tyfuns.pdf -- but I
Ah... I see that I have a bug in my proposal, perhaps corrected below.
2. In the second and fourth instances, the type variable x appears twice
in the parameters of the type function built from the fundep (a b - c).
This causes an error. If I try adding (x ~ x') to the context and
There is are two oddities with your example that I am confused by.
Code with fundeps is:
data Var a = Var Int (Maybe String)
data RHS a b = RHS a b
class Action t a b c | a - t, a b - c, a c - b
instance Action t () y y
instance
Gleb Alexeyev wrote:
Bryan O'Sullivan wrote:
I just posted a library named suffixtree to Hackage.
http://www.serpentine.com/software/suffixtree/
It implements Giegerich and Kurtz's lazy construction algorithm, with
a few tweaks for better performance and resource usage.
API docs:
Andrew Coppin wrote:
Anybody want to explain to me why this doesn't work?
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 6.6.1, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\/\/ /_/\/|_| Type :? for help.
Benjamin Franksen wrote:
Simon Peyton-Jones wrote:
| It is unfortunate that the [ghc] manual does not give the translation
rules, or at
| least the translation for the given example.
Hmm. OK. I've improved the manual with a URL to the main paper
David Ritchie MacIver wrote:
I was playing with some code for compiling regular expressions to finite
state machines and I ran into the following problem. I've solved it, but
I'm not terribly happy with my solution and was wondering if someone
could come up with a better one. :-)
Stefan O'Rear wrote:
On Fri, Aug 17, 2007 at 04:27:29PM -0400, Thomas Hartman wrote:
trying to compile regex-tdfa, I ran into another issue. (earlier I had a
cabal problem but that's resolved.)
there's a line that won't compile, neither for ghc 6.6.1 nor 6.7
import
Post the the library mailing list at [1] is the Boyer-Moore algorithm
implemented for strict and lazy bytestrings (and combinations thereof). It
finds all the overlapping instances of the pattern inside the target.
I have performance tuned it. But the performance for searching a strict
Discussion continues below quoted text...
Stefan O'Rear wrote:
On Tue, Jul 31, 2007 at 03:31:54PM -0700, David Roundy wrote:
On Mon, Jul 30, 2007 at 11:47:46AM +0100, Jon Fairbairn wrote:
ChrisK [EMAIL PROTECTED] writes:
And the readability is destroyed because you cannot do any type
Thomas Conway wrote:
One of the things that gets messy is that in lots of places you can
put either a thing or a reference to a thing (i.e. the name of a thing
defined elsewhere). For example, consider the production:
NamedNumber ::= identifier ( SignedNumber )
|
Justin Bailey wrote:
On 7/31/07, Donald Bruce Stewart [EMAIL PROTECTED] wrote:
jgbailey:
Also, be sure to compare against a naive search, optimised for
strict and lazy bytestrings,
http://hpaste.org/1803
If its not faster than those 2, then you're doing something wrong :)
-- Don
I am still working on improving your code.
And I have a Is this a bug? question:
The lookup = computeLookup pat defines lookup to take an Int which represents
the index into pat, where this index is 0 based and the 0th item is the head of
pat.
Now look at matchLength :: Int; matchLength = let
My optimized (and fixed) version of the code is attached. I benchmarked it
with:
module Main(main) where
import KMPSeq
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Lazy.Char8 as BC
infile = endo.dna
Modified by one character from the original copied from
And the readability is destroyed because you cannot do any type inference in
your head.
If you see
{
Matrix m = ;
Matrix x = m * y;
...;
}
Then you know very little about the possible types of y since can only conclude
that:
Matrix can be multiplied by one or more types 'sometype'
Melissa O'Neill wrote:
For example, consider yet another variant of power_list:
power_list l = [] : pow [[]] l where
pow acc [] = []
pow acc (x:xs) = acc_x ++ pow (acc ++ acc_x) xs
where acc_x = map (++ [x]) acc
By many standards, this version is inefficient, with plenty of
Jon Fairbairn wrote:
I currently only get f :: [t] - something, so if I later
discover that I need to change the input representation to
be more efficient than lists, I have to rewrite f. Wouldn't
it be so much nicer if I could simply add a declaration
f:: Stream s = s t - something
and get
Joel Reymont wrote:
So when should I use a STM TChan instead of a regular Chan?
On Oct 31, 2005, at 10:08 PM, ChrisK wrote:
Or perhaps a TChan, if that is more appropriate:
http://www.haskell.org/ghc/docs/latest/html/libraries/stm/Control-
Concurrent-STM-TChan.html
I like the curried
Or perhaps a TChan, if that is more appropriate:
http://www.haskell.org/ghc/docs/latest/html/libraries/stm/Control-Concurrent-STM-TChan.html
I like the curried command idiom:
do chan - newChan
let logToParent = writeChan chan
do tChan - newTChan
let logToParentSTM = writeTChan tChan
Try this:
This line is before the loop
sequence_ $ replicate 10 $ do
line 1
line 2
...
last line
This line is after the loop
Now you can use shorthand via
loopN n block = sequence_ $ replicate n block
So that you can write:
This line is before the loop
loopN 10 $ do
line 1
line 2
In GHC.Exts are the definitions
data Char = C# Char#
data Int = I# Int#
data Integer = S# Int# | J# Int# ByteArray#
data Double = D# Double#
data Float = F# Float#
Found with ghci using
:m + GHC.Exts
:browse GHC.Exts
Joel Reymont wrote:
Folks,
In
Rene de Visser wrote:
Hello,
I need to zip together multiple lists.
The lists are sorted by date, and each entry in the list represents data
for a time interval.
The time intervals between the lists may be missmatched from each other.
Does a single list have only disjoint intervals?
Well...your recursion will fail if (a:r) is matched against the empty
set. That will trigger your Exception.
So does your code avoid this ? No, it does not.
cus 2 [1,2,3,4,5] recurses
to cus 1 [2,3,4,5]
to cus 0 [3,4,5]
to cus (-1) [4,5]
to cus (-2) [5]
to cus
You would have to preempt the Standard Prelude. For ghc there is a
command line switch I have neer used: -fno-implicit-prelude
See section 7.3.5 in the GHC user's guide for more.
There are some internal caveats:
However, the standard Prelude Eq class is still used for the equality
test
Hi,
There are also STArray examples on the wiki at
http://haskell.org/hawiki/ImperativeHaskell
This includes a very high performance use of STUArray example (from
Autrijus), and a ST.Lazy example that I wrote that uses STArray.
--
Chris
___
Alistair Bayley wrote:
There are also STArray examples on the wiki at
http://haskell.org/hawiki/ImperativeHaskell
This includes a very high performance use of STUArray example (from
Autrijus), and a ST.Lazy example that I wrote that uses STArray.
Thanks. I saw these, but couldn't quite
The combinator is really elegant, but I want to ask a question about the
arrays that get built. The 3D array index is by (m,n,i) and a single
array should be good for all of the results.
If I say let {x=change 10 5; y=change 5 10;} then it looks like dp
(10,5,8) and dp (5,10,8) get evaluated.
Well, I don't have time to do more than comment, but here are few
improvements:
Sort the list of integers, highest at the front of the list.
(And perhaps remove duplicates with nub)
When you pop the first element you can already compute the range of
quantity you will need, and can perhaps
Okay, I like Cale's extra guard short circuit so much I must add it to
my pseudo-example.
Cale's guard:
amount `div` maximum coins maxCoins = [] -- optimisation
Mine, updated.
partition (x:xs) m k | xm = partition xs m k-- x is too big
parititon (x:_) m k | x*k m = []
(= x
coins)) over and over again.
Radu Grigore wrote:
On 7/13/05, ChrisK [EMAIL PROTECTED] wrote:
Sort the list of integers, highest at the front of the list.
(And perhaps remove duplicates with nub)
The first time I wrote in the comments that 'partition' takes a
decreasing list of integers
On Apr 20, 2005, at 10:04 PM, Alexandre Weffort Thenorio wrote:
As usual a beginner in Haskell. Trying to write a simple program in
haskel
shown below
outputLine keyno key orgFile = do
part1 - getLeft keyno orgFile
part2 - getRight keyno orgFile
total - part1 ++ (strUpper key) ++
And while I'm posting to the list, I'll send something I wish I had
found earlier.
I had wanted to write show several things, and writing show 10 times
was not clever.
And so I initially created an infix operator to put between everything
to do the showing, which was not much better.
But
compiling with optimisations turned on, there is no
such problem with the continuation-based version, memory usage appears
constant.
- Cale
On 4/14/05, ChrisK [EMAIL PROTECTED] wrote:
Thanks for the Cont example, David. But...
The MonadCont is clever and it works ... but then fails -- ghci does
You are correct. Moand.Cont yield even runs without -O optimizing,
just slower
...
Anyone have an idea why ghci can't garbage collect it?
Is this an actual bug or an innate quirk of the REPL ?
GHCi does not compile with optimizations, without -O the strictness
analyzer
isn't run.
The optimizer
(1.22 secs, 0 bytes)
*Main length $ take (10^8) zerosInf
1
(10.05 secs, 0 bytes)
*Main length $ take (10^9) zerosInf
10
(109.83 secs, 6 bytes)
--
Chris
On Apr 14, 2005, at 1:05 AM, David Menendez wrote:
ChrisK writes:
I was thinking to myself:
What in Haskell would give me a yield
Hi,
I was thinking to myself:
What in Haskell would give me a yield command like a Python generator?
And the answer was tell in Control.Monad.Writer -- and I wrote some
simple examples (see below).
Most Python code using yield would be translated to something much more
idiomatic in Haskell
101 - 183 of 183 matches
Mail list logo