Re: [Haskell-cafe] Abstracting ByteStrings

2008-01-22 Thread Henning Thielemann

On Tue, 22 Jan 2008, Chad Scherrer wrote:

> A lazy ByteString is an alternative to a String=[Char], where
> sacrificing some degree of laziness through "chunks" gives much
> greater performance in many applications. If I remember correctly, we
> could as well create an IntString, DoubleString, etc by filling the
> chunk arrays with different types.
>
> Now, this might only work for primitive types, but couldn't we extend
> it by taking a similar approach to NDP? For example, if we have (lazy)
> ByteString = [Chunk Char], then we could represent, say [Chunk (a,b)]
> as ([Chunk a], [Chunk b]), etc

Given a reasonable Storable instance of pairs you could use:
  http://code.haskell.org/~sjanssen/storablevector

> Is this reasonable? Do you think it would work? Or is all of this
> subsumed by fusion anyway?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] announcing darcs 2.0.0pre3

2008-01-22 Thread Bulat Ziganshin
Hello David,

Tuesday, January 22, 2008, 11:43:44 PM, you wrote:

> The third prerelease features (apart from numerous bug and performance
> regression fixes) a completely rewritten rollback command and new
> progress-reporting functionality. If darcs takes more than a couple of
> seconds for a given operation and provides you with no feedback as to what
> it's up to, let us know, so we can fine-tune the progress-reporting output!

btw, in my program, progress is output be separate thread each 0.1
second. operating threads just update global var with current state.
of course when operating thread need to interact with user, it just
sts another global var to False which prevents progress indicator
thread from showing anything

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] haskeem -- (almost) scheme in haskell

2008-01-22 Thread Uwe Hollerbach
Hello, haskellers, I am a total newbie in haskell, but I've been
making some mud pies that are coming out kinda pleasingly to my
admittedly biased eye. I found Jonathan Tang's excellent tutorial
"Write yourself a scheme in 48 hours" a few weeks ago, went through
and beyond that, and now have something that's starting to look
moderately like a real scheme interpreter. I've got much, though not
all, of the scheme number tower implemented, I have most of the core
syntactic forms (and, apply, begin, case cond, define, if, lambda,
let, let*, letrec, letrec*, or, quote, set!) and am working on a few
more (delay and force are well along, guard is also in progress but
less so), and I have implemented a small trace facility. It's still a
toy, but it's starting to be a toy with some nice dance moves. I think
it could do the majority of the code in SICP by now. If you'd like to
have a look, please surf over to
http://www.korgwal.com/software/haskeem/index.html. Feedback welcome!

best regards,
Uwe Hollerbach
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Draft chapters of "Real World Haskell" now publicly available

2008-01-22 Thread Wolfgang Jeltsch
Am Dienstag, 22. Januar 2008 15:58 schrieb Peter Verswyvelen:
> Wow, the full TOC looks very impressive indeed! Maybe add a chapter
> about reactive programming (Yampa and Conal's latest stuff that I don't
> understand yet) too? :-)
>
> Cheers,
> Peter

Covering reactive programming would indeed be interesting.

I want to add that there is no single way for doing reactive programming in 
Haskell.  There is Conal’s stuff, there is Yampa and there is “my” stuff 
(Grapefruit [1]) whereby the pros and cons of these approaches differ.  (And 
there is plenty of other stuff which doesn’t seem to be actively developed, 
like, for example, FranTk.)

Also note that reactive programming in Haskell is not as mature as, for 
instance, GUI programming with Gtk2Hs.  So it might not be wise to add a 
chapter on it now. Maybe in the second version of the book. :-) 

Best wishes,
Wolfgang

[1] 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: An idea - Feasibility and effort

2008-01-22 Thread Achim Schneider
Ben Franksen <[EMAIL PROTECTED]> wrote:

> Just out of curiosity: how do you plan to find out server locations
> (beyond the obvious top-level domain -> country heuristics)?
> 
$ whois  | grep Country


-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: An idea - Feasibility and effort

2008-01-22 Thread Ben Franksen
Vimal wrote:
> Idea 1:
> A Traceroute visualizer.
> 
> I saw the video on the London Haskell Group on how to create a game in
> Haskell, and loved the "rotating earth" part of the game. (Space
> Invaders or something like that). Combine the earth (with a Google
> earth touch) with a traceroute backend and animate packet routing via
> different cities live on the screen.
> 
> I like this idea. More of a fun project than a useful one. Probably
> Haskell isnt a good language to implement it, but as they say, one
> should never think about moulding a project to suit the language you
> code in.

Just out of curiosity: how do you plan to find out server locations (beyond
the obvious top-level domain -> country heuristics)?

Cheers
Ben

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Abstracting ByteStrings

2008-01-22 Thread Chad Scherrer
A lazy ByteString is an alternative to a String=[Char], where
sacrificing some degree of laziness through "chunks" gives much
greater performance in many applications. If I remember correctly, we
could as well create an IntString, DoubleString, etc by filling the
chunk arrays with different types.

Now, this might only work for primitive types, but couldn't we extend
it by taking a similar approach to NDP? For example, if we have (lazy)
ByteString = [Chunk Char], then we could represent, say [Chunk (a,b)]
as ([Chunk a], [Chunk b]), etc

Is this reasonable? Do you think it would work? Or is all of this
subsumed by fusion anyway?

-- 

Chad Scherrer

"Time flies like an arrow; fruit flies like a banana" -- Groucho Marx
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Precedence and associativity in a pretty-printer

2008-01-22 Thread Allan Clark

Edsko de Vries wrote:

Hi,

Is there a nice way to pretty-print such an expression with the minimal
number of brackets? I can come up with something, but I'm sure somebody
thought hard about this problem before and came up with a really nice
solution :)

Any hints or pointers would be appreciated,

Thanks,

  

You might find Norman Ramsey's paper on unparsing helpful:

http://citeseer.ist.psu.edu/194913.html
or google for
Norman Ramsey Unparsing

regards
allan


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Precedence and associativity in a pretty-printer

2008-01-22 Thread Ryan Ingram
On 1/22/08, Benja Fallenstein <[EMAIL PROTECTED]> wrote:
> Take a look at how Haskell's derived Show instances do it? :-)
>
> http://www.haskell.org/onlinereport/derived.html#sect10.4

I hate how Haskell handles precedence:
1) Arbitrary magic numbers for precedence, which isn't very natural.
2) Impossible to define operators that have higher precedence than
function application.
3) Impossible to define unary operators.
4) Because of (1), impossible to define an operator with higher
precedence than + but lower precedence than *, or similar.

When I was working through SPJ's "functional languages" book, (see
http://research.microsoft.com/~simonpj/Papers/pj-lester-book/) I was
determined to do a better job.  It's not that hard to define a partial
ordering between operators instead of using fixed categories for
precedences, so that's what I did.

So, given an environment which gives you a partial ordering between
operators and fixty declarations (left, right, or nofix), you can
write out expressions pretty easily:

type Name = String
data Operator = OpFunAp | Op Name

data PartialOrdering = PoLT | PoGT | PoEQ | PoNC deriving Eq
data Fixity = FixLeft | FixRight | FixNone deriving Eq

-- type FixityEnv = exercise for the reader
--   with operations:
-- contains :: FixityEnv -> Operator -> Bool
-- comparePrec :: FixityEnv -> Operator -> Operator -> PartialOrdering
-- fixity :: FixityEnv -> Operator -> Fixity

-- unary operators are also an exercise for the reader
-- you could also improve this to use ShowS and (.)
-- instead of String and (++) to avoid quadratic slowdown.

data FixityContext = FcNone | FcLeft Operator | FcRight Operator

parens :: Bool -> String -> String
parens False s = s
parens True s = "(" ++ s ++ ")"

print :: FixityEnv -> FixityContext -> Exp -> String
print env ctx (Ap (Ap (Sym operator) left) right)
| env `contains` (Op operator) = printBinOp env ctxt operator left right
print env ctx (Ap left right) = printAp env ctxt left right
print env ctx (Sym name) = parens (env `contains` Op name) name

printBinOp :: FixityEnv -> FixityContext -> Name -> Exp -> Exp -> String
printBinOp env ctxt op left right =
parens (needsParens env ctxt (Op op)) $ concat [
print env (FcLeft $ Op op) left,
" " ++ op ++ " ",
print env (FcRight $ Op op) right ]

printAp :: FixityEnv -> FixityContext -> Exp -> Exp -> String
printAp env ctxt op left right =
parens (needsParens env ctxt OpFunAp) $ concat [
print env (FcLeft OpFunAp) left,
" ",
print env (FcRight OpFunAp) right ]

needsParens :: FixityEnv -> FixityContext -> Operator -> Bool
needsParens _ FcNone _ = False
needsParens env (FcLeft ctxt) op
| comparePrec env ctxt op == PoLT = False
| comparePrec env ctxt op == PoGT = True
| comparePrec env ctxt op == PoNC = True
-- otherwise the two operators have the same precedence
| fixity ctxt /= fixity op = True
| fixity ctxt == FixLeft = False
| otherwise = True
needsParens env (FcRight ctxt) op
| comparePrec env ctxt op == PoLT = False
| comparePrec env ctxt op == PoGT = True
| comparePrec env ctxt op == PoNC = True
-- otherwise the two operators have the same precedence
| fixity ctxt /= fixity op = True
| fixity ctxt == FixRight = False
| otherwise = True
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Irrefutable pattern love and new regex engine.

2008-01-22 Thread Stefan O'Rear
On Tue, Jan 22, 2008 at 02:09:05PM -0800, Ryan Ingram wrote:
> > > On Tue, 2008-01-22 at 11:55 -0500, Michael Speer wrote:
> > > >   rexn ns pps = let ( ~( xs , rps ) ,
> > > >   ~( ~( nxs ) ,
> > > >  ~( rxs , rrps ) ) ) = ( exn nxs pps ,
> 
> > Not one of the lazy marks was required in the current version.
> 
> Pattern bindings via let are always irrefutable; the ~s here are all 
> redundant.

False; let's irrefutability only applies at the topmost level.

Prelude> let (a,b) = undefined in 2
2
Prelude> let (a,(b,c)) = (2,undefined) in a
*** Exception: Prelude.undefined
Prelude> let (a,~(b,c)) = (2,undefined) in a
2

Stefan


signature.asc
Description: Digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Irrefutable pattern love and new regex engine.

2008-01-22 Thread Ryan Ingram
> > On Tue, 2008-01-22 at 11:55 -0500, Michael Speer wrote:
> > >   rexn ns pps = let ( ~( xs , rps ) ,
> > >   ~( ~( nxs ) ,
> > >  ~( rxs , rrps ) ) ) = ( exn nxs pps ,

> Not one of the lazy marks was required in the current version.

Pattern bindings via let are always irrefutable; the ~s here are all redundant.

This took me a little while to figure out; I was browsing
Control.Monad.State.Lazy and trying to figure out how it was different
than Control.Monad.State.Strict; they look almost exactly the same.
But then I noticed code that looked like the following:

(strict)
m >>= f = State $ \s ->
case runState m s of (a, s') -> runState (f a) s'

(lazy)
m >>= f = State $ \s ->
let (a, s') = runState m s in runState (f a) s'

The strict code deconstructs the pair in a case expression, so
"runState m s" will always get evaluated at least enough to know that
it is going to return a pair and not _|_.

The lazy code immediately calls (f a) and m may not get evaluated at
all if f is lazy and doesn't access the state.

  -- ryan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] announcing darcs 2.0.0pre3

2008-01-22 Thread David Roundy
We are happy to announce the third prerelease version of darcs 2! Darcs 2
features numerous improvements, and it seems that we have fixed most of the
regressions, so we're looking for help, from users willing to try this
release out. Read below, to see how you can benefit from this new release,
and how you can help us to make the final darcs 2 release the best ever!

The third prerelease features (apart from numerous bug and performance
regression fixes) a completely rewritten rollback command and new
progress-reporting functionality. If darcs takes more than a couple of
seconds for a given operation and provides you with no feedback as to what
it's up to, let us know, so we can fine-tune the progress-reporting output!

I would especially like to thank Mark Stosberg for his tireless work
triaging old bugs in our bug tracker and writing tests to be added to our
test suite for those still present!

For more details, and instructions on obtaining darcs 2.0.0pre3, see:

http://wiki.darcs.net/index.html/DarcsTwo

David
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ghc6.8: hiding uninstalled package?

2008-01-22 Thread Brandon S. Allbery KF8NH


On Jan 22, 2008, at 14:57 , Ben Franksen wrote:

The 'ghc-pkg list dataenc | grep dataenc' cannot be avoided AFAIK.  
Using
some make-fu you can avoid the conditional, though, thus making it  
a bit

more generic:


You can also use $(findstring) instead of piping to grep.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: ghc6.8: hiding uninstalled package?

2008-01-22 Thread Ben Franksen
Magnus Therning wrote:
> I stumbled on this behaviour because I was writing a
> makefile
> for my unit/quickcheck tests.  I need to make sure that the correct module
> is used, hence I need to hide it if it's installed.  I ended up with the
> following in order to work around the issue:
> 
> ifeq (,$(shell ghc-pkg list dataenc | grep dataenc))
> GHCOPTS = -fhpc -isrc
> else
> GHCOPTS = -fhpc -hide-package dataenc -isrc
> endif
> 
> % : %.hs
> ghc --make $(GHCOPTS) $<
> 
> Is there a better way to do it?

The 'ghc-pkg list dataenc | grep dataenc' cannot be avoided AFAIK. Using
some make-fu you can avoid the conditional, though, thus making it a bit
more generic:

PACKAGES_TO_HIDE := bla mtl blub base

EXISTING_PACKAGES_TO_HIDE :=\
 $(foreach p,$(PACKAGES_TO_HIDE), $(shell ghc-pkg list $p | grep $p))

GHC_HIDE_PACKAGE_OPTS = $(EXISTING_PACKAGES_TO_HIDE:%=-hide-package %)

GHCOPTS = -fhpc -isrc $(GHC_HIDE_PACKAGE_OPTS)

Cheers
Ben

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Irrefutable pattern love and new regex engine.

2008-01-22 Thread Michael Speer
On Jan 22, 2008 11:59 AM, Derek Elkins <[EMAIL PROTECTED]> wrote:
> On Tue, 2008-01-22 at 11:55 -0500, Michael Speer wrote:
> > I've been using the creation of a regular expression engine as an
> > ongoing project to learn Haskell.  Last night I created the newest
> > iteration.
> >
> > My love for the irrefutable pattern can be found in the definition of
> > the rexn ( apply repetition to extracted nodes ) function below.
> > /snip
> >   rexn ns pps = let ( ~( xs , rps ) ,
> >   ~( ~( nxs ) ,
> >  ~( rxs , rrps ) ) ) = ( exn nxs pps ,
>
> ~nxs is redundant.
>
> > Beautiful, beautiful lazy execution and irrefutable pattern matching.
> > The data flow is able to easily twist in and out of functions, even as
> > an argument to the function call that creates it.
> >
> > Is this kind of usage normal?
>
> No.  Irrefutable patterns are usually the right thing to use in circular
> programs, but usually you only need a few well-placed irrefutable
> patterns.  I suspect most (all?) of yours are unnecessary.  The use of

You're absolutely right.  Thank you. I am learning this on my own and
had originally figured out how to use them by nesting like that.  I
had written something like this without them and got it to work on
discovering and adding them.  Not one of the lazy marks was required
in the current version.  The implicit lazy bindings carried everything
through fine.  Perhaps it was the nested tuples that required them in
the other version.  It would smash the stack without them.

> tuples also feels a bit excessive as an impression.  I'd have to really
> look to decide, but it gives me the feeling that a data structure should
> be being used somewhere.  Your many unnecessary parentheses bothers me,
> but I tend to dislike any unnecessary ones except where there might
> reasonably be some ambiguity while reading.  I also recommend trying a
> different way of laying out your code as most of it is wrapped below and
> most of -that- is due to it being excessively indented.  Perhaps pull
> some of the lambdas into functions.
>

I didn't consider the wrapping when I posted.  It is easier read where
I posted it in my blog :
http://michaelspeer.blogspot.com/2008/01/irrefutable-pattern-love.html

Thanks.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Ian Lynagh
On Tue, Jan 22, 2008 at 03:59:24PM +, Magnus Therning wrote:
> 
> Yes, of course, stupid me.  But it is still the UTF-8 representation of "ö",
> not Latin-1, and this brings me back to my original question, is this an
> intentional change in 6.8?

Yes (in 6.8.2, to be precise).

It's in the release notes:

http://www.haskell.org/ghc/docs/6.8.2/html/users_guide/release-6-8-2.html
GHCi now treats all input as unicode, except for the Windows console
where we do the correct conversion from the current code page.


Thanks
Ian

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Precedence and associativity in a pretty-printer

2008-01-22 Thread Benja Fallenstein
Hi Edsko,

On Jan 22, 2008 7:34 PM, Edsko de Vries <[EMAIL PROTECTED]> wrote:
> Is there a nice way to pretty-print such an expression with the minimal
> number of brackets? I can come up with something, but I'm sure somebody
> thought hard about this problem before and came up with a really nice
> solution :)

Take a look at how Haskell's derived Show instances do it? :-)

http://www.haskell.org/onlinereport/derived.html#sect10.4

- Benja
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Precedence and associativity in a pretty-printer

2008-01-22 Thread Edsko de Vries
Hi,

Suppose we have some algebraic datatype describing an expression
language containing the usual suspects (various binary arithmetic
operators such as addition, subtraction, multiplication, division,
exponentiation, function abstraction and application, etc.) each with
their own precendence (multiplication binds stronger than addition) and
associativity (function application is left associative, exponentiation
is right associative, addition is associative, etc.) 

Is there a nice way to pretty-print such an expression with the minimal
number of brackets? I can come up with something, but I'm sure somebody
thought hard about this problem before and came up with a really nice
solution :)

Any hints or pointers would be appreciated,

Thanks,

Edsko
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Irrefutable pattern love and new regex engine.

2008-01-22 Thread Derek Elkins
On Tue, 2008-01-22 at 11:55 -0500, Michael Speer wrote:
> I've been using the creation of a regular expression engine as an
> ongoing project to learn Haskell.  Last night I created the newest
> iteration.
> 
> My love for the irrefutable pattern can be found in the definition of
> the rexn ( apply repetition to extracted nodes ) function below.
> /snip
>   rexn ns pps = let ( ~( xs , rps ) ,
>   ~( ~( nxs ) ,
>  ~( rxs , rrps ) ) ) = ( exn nxs pps ,

~nxs is redundant.

> Beautiful, beautiful lazy execution and irrefutable pattern matching.
> The data flow is able to easily twist in and out of functions, even as
> an argument to the function call that creates it.
> 
> Is this kind of usage normal?

No.  Irrefutable patterns are usually the right thing to use in circular
programs, but usually you only need a few well-placed irrefutable
patterns.  I suspect most (all?) of yours are unnecessary.  The use of
tuples also feels a bit excessive as an impression.  I'd have to really
look to decide, but it gives me the feeling that a data structure should
be being used somewhere.  Your many unnecessary parentheses bothers me,
but I tend to dislike any unnecessary ones except where there might
reasonably be some ambiguity while reading.  I also recommend trying a
different way of laying out your code as most of it is wrapped below and
most of -that- is due to it being excessively indented.  Perhaps pull
some of the lambdas into functions.

> 
> Any and all comments, suggestions, refutations, and criticisms are welcome.
> 
> -- regular expression engine -- (c) 2008 michael speer
> 
> import Char ( isSpace )
> -- import Debug.Trace ( trace )
> 
> xor :: Bool -> Bool -> Bool
> xor True  a = not a
> xor False a = a
> 
> data RxToken = RxStart -- matchable start of target string
>  | RxChar Char -- a literal character to match
>  | RxBound -- inserted wherever alphanums touch whitespace
>  | RxEnd   -- matchable end of target string
>  | RxEOF   -- an additional token to push through to
> catch anything trying for RxEnd
>-- RxEOF is never matched.
>deriving ( Show )
> 
> rxTokenize tts = RxStart : case tts of
>  []-> RxEnd : RxEOF : []
>  tts@(t:_) -> case not $ isSpace t of
> True  -> RxBound : rxt tts
> False -> rxt tts
> where
>   rxt (t:[]) | not $ isSpace t = RxChar t : RxBound : RxEnd : RxEOF : []
>  | otherwise   = RxChar t : RxEnd : RxEOF : []
>   rxt (t:ts@(t':_)) | isSpace t `xor` isSpace t' = RxChar t :
> RxBound : rxt ts
> | otherwise  = RxChar t : rxt ts
> 
> data RxTransform = RxTransform ( RxNode -> RxToken -> [ RxNode ] )
>  | RxNullTransform
> 
> data RxNode = RxActive { rxTransforms :: [RxTransform] ,
>  rxMatched:: String ,
>  rxNumSubs:: Integer ,
>  rxSubExprs   :: [ String ] }
> | RxComplete { rxMatched :: String ,
>rxNumSubs :: Integer ,
>rxSubExprs :: [ String ] }
> 
> instance Show RxNode where
> show (RxComplete matched _ _) = ""
> 
> data RxDepth = RxTop | RxSub deriving ( Show )
> 
> rxCompile pps = let ( xs , rps ) = oexn [success] RxTop pps
> in case length rps of
>  0 -> RxActive { rxTransforms = xs ,
>  rxMatched= [] ,
>  rxNumSubs=  0 ,
>  rxSubExprs   = [] }
>  _ -> error $ "Not all of pattern consumed :
> remains : " ++ rps
> where
>   -- or together different expression sections -- (a|b|c)
>   oexn ns  RxTop [] = ( ns , [] )
>   oexn _  RxSub  [] = error "Pattern ended while still in sub expression"
>   oexn ns d pps = let ( ~( xs  , rps  ) ,
> ~( nxs , nrps ) ) = ( aexn ns pps ,
>   case rps of
> ('|':rr) ->
> let ( inxs , irps ) = oexn ns d rr
> in
> ( xs ++ inxs , irps )
> (')':rr) -> case d of
> 
> RxTop -> error "Erroneous close parenthesis in pattern "
> 
> RxSub -> ( xs , rr )
> []   -> case d of
> 
> RxTop -> ( xs , [] )
> 
> RxSub -> error "End of pattern while still in sub expression" )
>   in ( nxs , nrps )
>   -- and together extracted nodes in a given expression segment -- abd?dfs
>   

Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Derek Elkins
On Tue, 2008-01-22 at 07:45 -0200, Felipe Lessa wrote:
> 2008/1/22 Magnus Therning <[EMAIL PROTECTED]>:
> > I vaguely remember that in GHC 6.6 code like this
> >
> >   length $ map ord "a string"
> >
> > being able able to generate a different answer than
> >
> >   length "a string"
> 
> I guess it's not very difficult to prove that
> 
>  ∀ f xs.  length xs == length (map f xs)
> 
> even in the presence of seq.

This is the free theorem of length.  For it to be wrong, parametric
polymorphism would have to be incorrectly implemented.  Even seq makes
no difference (in this case.)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Jules Bean

Magnus Therning wrote:
Yes, of course, stupid me.  But it is still the UTF-8 representation of 
"ö", not Latin-1, and this brings me back to my original question, is 
this an intentional change in 6.8?


 > map ord "ö"
[246]
 > map ord "åɓz𝐀"
[229,595,65370,119808]

6.8 produces Unicode code points rather then a particular encoding.


The key point here is this has nothing to do with GHC.

GHC's behaviour has not changed in this regard.

This is about GHCi! [And, to some extent, the behaviour of whatever 
shell / terminal emulator you run ghci in]


Sounds like a pedantic difference, but it's not.

The difference here is what GHCi is feeding into your haskell code when 
you type the sequence "ö" at a ghci prompt, rather than anything 
different about the underlying behaviour of map, ord, length, show, 
putStr. map, ord, length, show, putStr have not changed from 6.6 to 6.8.


I don't have 6.8 handy myself but from your demonstration is would 
appear that 6.8's ghci correctly understands whatever input encoding is 
being used in whatever terminal environment you are choosing to run ghci 
within.


Whereas, 6.6's ghci was using a single-byte terminal approach, and your 
terminal environment was encoding ö as two characters.


Jules
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Irrefutable pattern love and new regex engine.

2008-01-22 Thread Michael Speer
I've been using the creation of a regular expression engine as an
ongoing project to learn Haskell.  Last night I created the newest
iteration.

My love for the irrefutable pattern can be found in the definition of
the rexn ( apply repetition to extracted nodes ) function below.
/snip
  rexn ns pps = let ( ~( xs , rps ) ,
  ~( ~( nxs ) ,
 ~( rxs , rrps ) ) ) = ( exn nxs pps ,
   case rps of
 ('?':'?':rr)
-> ( ( ns ) ,

( ns ++ xs , rr ) )
 ('?':rr)
-> ( ( ns ) ,

( xs ++ ns , rr ) )
/snip

Beautiful, beautiful lazy execution and irrefutable pattern matching.
The data flow is able to easily twist in and out of functions, even as
an argument to the function call that creates it.

Is this kind of usage normal?

Any and all comments, suggestions, refutations, and criticisms are welcome.

-- regular expression engine -- (c) 2008 michael speer

import Char ( isSpace )
-- import Debug.Trace ( trace )

xor :: Bool -> Bool -> Bool
xor True  a = not a
xor False a = a

data RxToken = RxStart -- matchable start of target string
 | RxChar Char -- a literal character to match
 | RxBound -- inserted wherever alphanums touch whitespace
 | RxEnd   -- matchable end of target string
 | RxEOF   -- an additional token to push through to
catch anything trying for RxEnd
   -- RxEOF is never matched.
   deriving ( Show )

rxTokenize tts = RxStart : case tts of
 []-> RxEnd : RxEOF : []
 tts@(t:_) -> case not $ isSpace t of
True  -> RxBound : rxt tts
False -> rxt tts
where
  rxt (t:[]) | not $ isSpace t = RxChar t : RxBound : RxEnd : RxEOF : []
 | otherwise   = RxChar t : RxEnd : RxEOF : []
  rxt (t:ts@(t':_)) | isSpace t `xor` isSpace t' = RxChar t :
RxBound : rxt ts
| otherwise  = RxChar t : rxt ts

data RxTransform = RxTransform ( RxNode -> RxToken -> [ RxNode ] )
 | RxNullTransform

data RxNode = RxActive { rxTransforms :: [RxTransform] ,
 rxMatched:: String ,
 rxNumSubs:: Integer ,
 rxSubExprs   :: [ String ] }
| RxComplete { rxMatched :: String ,
   rxNumSubs :: Integer ,
   rxSubExprs :: [ String ] }

instance Show RxNode where
show (RxComplete matched _ _) = ""

data RxDepth = RxTop | RxSub deriving ( Show )

rxCompile pps = let ( xs , rps ) = oexn [success] RxTop pps
in case length rps of
 0 -> RxActive { rxTransforms = xs ,
 rxMatched= [] ,
 rxNumSubs=  0 ,
 rxSubExprs   = [] }
 _ -> error $ "Not all of pattern consumed :
remains : " ++ rps
where
  -- or together different expression sections -- (a|b|c)
  oexn ns  RxTop [] = ( ns , [] )
  oexn _  RxSub  [] = error "Pattern ended while still in sub expression"
  oexn ns d pps = let ( ~( xs  , rps  ) ,
~( nxs , nrps ) ) = ( aexn ns pps ,
  case rps of
('|':rr) ->
let ( inxs , irps ) = oexn ns d rr
in
( xs ++ inxs , irps )
(')':rr) -> case d of

RxTop -> error "Erroneous close parenthesis in pattern "

RxSub -> ( xs , rr )
[]   -> case d of

RxTop -> ( xs , [] )

RxSub -> error "End of pattern while still in sub expression" )
  in ( nxs , nrps )
  -- and together extracted nodes in a given expression segment -- abd?dfs
  aexn ns pps = let ( ~( xs  , rps  ) ,
  ~( nxs , nrps ) ) = ( rexn nxs pps ,
case rps of
  ('|':_) -> ( ns , rps )
  (')':_) -> ( ns , rps )
  []  -> ( ns , rps )
  _   -> aexn ns rps )
in ( xs , nrps )
  -- replication application - weee!
  rexn ns pps = let ( ~( xs , rps ) ,
  ~( ~( nxs ) ,
 ~( rxs , rrps ) ) ) = ( exn nxs pps ,
   

Re: [Haskell-cafe] Announce: mersenne-random 0.1, very fast pseudo-random number generation for Haskell

2008-01-22 Thread Don Stewart
gale:
> Don Stewart wrote:
> > I'm pleased to announce the creation of the mersenne-random package,
> 
> Excellent! We were just discussing that.
> 
> > ...the implementation we bind to is heavily
> > impure, so only a single generator is possible per-process (splitting
> > generators is also not supported)...
> > Note that the cpu isn't detected automatically, so to turn on SIMD flags
> > for your cpu, you'll need to build it by hand
> 
> These are critical pieces of information. The only place I see them
> is in this email. Perhaps you should add them to the description on
> the Hackage page? Or at least to the README?

It is mentioned in the readme, and the cabal file.

> 
> > Some light abstractions are implemented over the raw C interface, including
> > a type class for SFMT-generated Haskell values, and lists of those values.
> 
> Haddocks for this?

It is fully haddocked, with examples. I'm waiting on hackage.haskell.org
to regenerate the docs. Until then, docs are here:

http://code.haskell.org/~dons/docs/mersenne-random/

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] [Fwd: Invitation for MathematiKa '08 : projectEuler format]

2008-01-22 Thread anshuman
 Original Message 
Subject: Invitation for MathematiKa '08 : projectEuler format
From:[EMAIL PROTECTED]
Date:Mon, January 21, 2008 11:30 am
To:  haskell-cafe@haskell.org
--

Hello Math Enthusiast,

IIIT-Hyderabad, India cordially invites you to be a part of Mathematika
'08, an online competition that emphasizes on fusion of mathematics and
computing.

Where: http://felicity.iiit.ac.in/~math
When: 4th February, 2008

This Online Math Contest will consist of 10-12 problems made randomly from
different domains of existing Math. All problem statements will be visible
to the contestant from the start of contest spanning over a 10 hour
period. The solution to each problem would be an integer or a floating
point number which is to be submitted in real-time.

One Minute Rule: The problems are designed in a way that support 1 minute
rule which means that an efficient implementation will allow a solution to
be obtained on a modestly powered computer in less than one minute.

Also, make sure to bring your appetite for math, programming and fun.
There will be plenty of all three to go around.

Regards
Mathematika Team
http://felicity.iiit.ac.in/~math



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Peter Verswyvelen

Ian Lynagh wrote:

Prelude Data.Char> map ord "ö"
[195,182]
Prelude Data.Char> length "ö"
2

there are actually 2 bytes there, but your terminal is showing them as
one character.
  
So let's all switch to unicode ASAP and leave that horrible 
multi-byte-string-thing behind us?


Cheers,
Peter




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Magnus Therning
On 1/22/08, Ian Lynagh <[EMAIL PROTECTED]> wrote:
>
> On Tue, Jan 22, 2008 at 03:16:15PM +, Magnus Therning wrote:
> > On 1/22/08, Duncan Coutts <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > On Tue, 2008-01-22 at 09:29 +, Magnus Therning wrote:
> > > > I vaguely remember that in GHC 6.6 code like this
> > > >
> > > >   length $ map ord "a string"
> > > >
> > > > being able able to generate a different answer than
> > > >
> > > >   length "a string"
> > >
> > > That seems unlikely.
> >
> >
> > Unlikely yes, yet I get the following in GHCi (ghc 6.6.1, the version
> > currently in Debian Sid):
> >
> > > map ord "a"
> > [97]
> > > map ord "ö"
> > [195,182]
>
> In 6.6.1:
>
> Prelude Data.Char> map ord "ö"
> [195,182]
> Prelude Data.Char> length "ö"
> 2
>
> there are actually 2 bytes there, but your terminal is showing them as
> one character.


Yes, of course, stupid me.  But it is still the UTF-8 representation of "ö",
not Latin-1, and this brings me back to my original question, is this an
intentional change in 6.8?

> map ord "ö"
[246]
> map ord "åɓz𝐀"
[229,595,65370,119808]

6.8 produces Unicode code points rather then a particular encoding.

/M
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Draft chapters of "Real World Haskell" now publicly available

2008-01-22 Thread Peter Verswyvelen
Wow, the full TOC looks very impressive indeed! Maybe add a chapter 
about reactive programming (Yampa and Conal's latest stuff that I don't 
understand yet) too? :-)


Cheers,
Peter

Bryan O'Sullivan wrote:

Paul Moore wrote:

  

I'm posting here because there doesn't seem to be an "overall" comment
section, but the TOC seems to cover less ground than I expected. Is
the TOC meant to be complete?



No, it's less than a third of the whole thing.

Here's the announcement from last May, including a more detailed TOC:
http://www.realworldhaskell.org/blog/2007/05/23/real-world-haskell-its-time/

We've since added a few chapters, and I wouldn't be surprised if we
subtract a couple in the interests of length later in the process.

http://www.haskell.org/mailman/listinfo/haskell-cafe


  


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Reinier Lamers

Ian Lynagh wrote:

On Tue, Jan 22, 2008 at 03:16:15PM +, Magnus Therning wrote:
  

On 1/22/08, Duncan Coutts <[EMAIL PROTECTED]> wrote:


On Tue, 2008-01-22 at 09:29 +, Magnus Therning wrote:
  

I vaguely remember that in GHC 6.6 code like this

  length $ map ord "a string"

being able able to generate a different answer than

  length "a string"


That seems unlikely.
  

Unlikely yes, yet I get the following in GHCi (ghc 6.6.1, the version
currently in Debian Sid):



map ord "a"
  

[97]


map ord "ö"
  

[195,182]



In 6.6.1:

Prelude Data.Char> map ord "ö"
[195,182]
Prelude Data.Char> length "ö"
2

there are actually 2 bytes there, but your terminal is showing them as
one character.
Still, that seems weird to me. A Haskell Char is a Unicode character. An 
"ö" is either one character (unicode point 0xF6) (which, in UTF-8, is 
coded as two bytes) or a combination of an "o" with an umlaut (Unicode 
point 776). But because the last character is not 776, the "ö" here 
should just be one character. I'd suspect that the two-character string 
comes from the terminal speaking UTF-8 to GHC expecting Latin-1. GHC 6.8 
expects UTF-8, so all is fine.


On my MacBook (OS X 10.4), 'ö' also immediately expands to "\303\266" 
when I type it in my terminal, even outside GHCi. That suggests that the 
terminal program doesn't handle Unicode and immediately escapes weird 
characters.


Regards,
Reinier
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Bulat Ziganshin
Hello Duncan,

Tuesday, January 22, 2008, 1:36:44 PM, you wrote:

> Yes. GHC 6.8 treats .hs files as UTF-8 where it previously treated them
> as Latin-1.

afair, it was changed since 6.6


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Newbie question

2008-01-22 Thread Bulat Ziganshin
Hello Jon,

Tuesday, January 22, 2008, 1:04:48 PM, you wrote:

>> i.e. you should have other functions that produce A from Integer and
>> at the last end this means that class A should provide some way to
>> do it

> I'm not sure we're using the same terminology. In the
> example I gave, the class A doesn't provide anything from
> Integer to a, unless defining an overloaded function outside
> the class definition counts as the class providing something.

you are perfectly right. but don't forget that this is not theoretical
discussion but *newbie* question so i hope that my answer is just what
he try to realize. anyway, he got them both

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Ian Lynagh
On Tue, Jan 22, 2008 at 03:16:15PM +, Magnus Therning wrote:
> On 1/22/08, Duncan Coutts <[EMAIL PROTECTED]> wrote:
> >
> >
> > On Tue, 2008-01-22 at 09:29 +, Magnus Therning wrote:
> > > I vaguely remember that in GHC 6.6 code like this
> > >
> > >   length $ map ord "a string"
> > >
> > > being able able to generate a different answer than
> > >
> > >   length "a string"
> >
> > That seems unlikely.
> 
> 
> Unlikely yes, yet I get the following in GHCi (ghc 6.6.1, the version
> currently in Debian Sid):
> 
> > map ord "a"
> [97]
> > map ord "ö"
> [195,182]

In 6.6.1:

Prelude Data.Char> map ord "ö"
[195,182]
Prelude Data.Char> length "ö"
2

there are actually 2 bytes there, but your terminal is showing them as
one character.


Thanks
Ian

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Magnus Therning
On 1/22/08, Duncan Coutts <[EMAIL PROTECTED]> wrote:
>
>
> On Tue, 2008-01-22 at 09:29 +, Magnus Therning wrote:
> > I vaguely remember that in GHC 6.6 code like this
> >
> >   length $ map ord "a string"
> >
> > being able able to generate a different answer than
> >
> >   length "a string"
>
> That seems unlikely.


Unlikely yes, yet I get the following in GHCi (ghc 6.6.1, the version
currently in Debian Sid):

> map ord "a"
[97]
> map ord "ö"
[195,182]

Funky, isn't it? ;-)

Easy!
>
> Prelude> 'å' == '\229'
> True
> Prelude> 'å' == Char.chr 229
> True
>
> Remember, when you type:
> Prelude> 'å'
>
> what you really get is:
> Prelude> putStrLn (show 'å')
>
> So perhaps what is confusing you is the Show instance for Char which
> converts Char -> String into a portable ascii representation.


Have you tried putting any of this into GHCi (6.6.1)?  Any line with 'å'
results in the following for me:

> 'å'
:1:2: lexical error in string/character literal at character
'\165'
> "å"
"\195\165"

Somewhat disappointing.  GHCi 6.8.2 does perform better though.

/M
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Draft chapters of "Real World Haskell" now publicly available

2008-01-22 Thread Paul Moore
On 22/01/2008, Bryan O'Sullivan <[EMAIL PROTECTED]> wrote:
> Paul Moore wrote:
>
> > I'm posting here because there doesn't seem to be an "overall" comment
> > section, but the TOC seems to cover less ground than I expected. Is
> > the TOC meant to be complete?
>
> No, it's less than a third of the whole thing.

Ah, that's what I thought. Thanks for the pointer to the full thing -
I'd missed that one.

Paul.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Hangman game

2008-01-22 Thread Yitzchak Gale
Ronald Guida wrote:
>> For a Hangman game, the only time I need to change the probability
>> distribution is if I load a new word list.  If I wanted to be able to
>> load a new word list, then perhaps I need to carry the word list
>> inside the GameState as well?

Achim Schneider wrote:
> What about carrying a list of Strings inside the State?

Right, I think you need that if the word list can be reloaded,
or selected at run time.

> Write a RandomGen and Random instance that return some
> dictionary file in random order.

Whoa, I don't think we need to go that far. But good idea
to extract out selecting the random word into a separate
function. Later on you may want to change how that works,
e.g., you may use larger word lists and switch to reading
the word each time from a file. So this function should
return the word in your monad.

Changing the probability distribution sounds like a stretch,
I can't think of too many games where you would ever want
to do that at run time. In a game with real-time feedback,
you may want to fiddle with the generator for speed reasons.

Regards,
Yitz
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Draft chapters of "Real World Haskell" now publicly available

2008-01-22 Thread Bryan O'Sullivan
Paul Moore wrote:

> I'm posting here because there doesn't seem to be an "overall" comment
> section, but the TOC seems to cover less ground than I expected. Is
> the TOC meant to be complete?

No, it's less than a third of the whole thing.

Here's the announcement from last May, including a more detailed TOC:
http://www.realworldhaskell.org/blog/2007/05/23/real-world-haskell-its-time/

We've since added a few chapters, and I wouldn't be surprised if we
subtract a couple in the interests of length later in the process.

http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Draft chapters of "Real World Haskell" now publicly available

2008-01-22 Thread Paul Moore
On 21/01/2008, Bryan O'Sullivan <[EMAIL PROTECTED]> wrote:
> John, Don and I are pleased to announce the beginning of the public beta
> programme for our upcoming book, "Real World Haskell".  For further
> details, please see the following blog entry:
>
> http://www.realworldhaskell.org/blog/2008/01/21/finally-the-public-beta-programme-begins/
>
> Thanks to all of the Haskell community members who have so far performed
> sterling service in commenting on our closed drafts.
>
> We look forward to your feedback!

I'm posting here because there doesn't seem to be an "overall" comment
section, but the TOC seems to cover less ground than I expected. Is
the TOC meant to be complete? In one of the earlier blog postings, you
said you were planning on covering OpenGL, generic programming, web
servers, debugging and profiling. None of these topics seem to have an
obvious plane in the current TOC.

Am I right in expecting the TOC to be expanded as time goes on? What's
there at present seems OK (I haven't read anything in detail yet) but
doesn't seem to cover substantially different ground than the various
other books and tutorials I've seen.

Paul.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Hangman game

2008-01-22 Thread Achim Schneider
Ronald Guida <[EMAIL PROTECTED]> wrote:

> For a Hangman game, the only time I need to change the probability
> distribution is if I load a new word list.  If I wanted to be able to
> load a new word list, then perhaps I need to carry the word list
> inside the GameState as well?
>
What about carrying a list of Strings inside the State? Write a
RandomGen and Random instance that return some dictionary file in
random order.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Re: Newbie question

2008-01-22 Thread Bulat Ziganshin
Hello Peter,

Tuesday, January 22, 2008, 12:36:49 AM, you wrote:

> Hey, I knew about the forall (I use that to represent OO style
> collections, very handy), but not about the exists. Thanks. But GHC
> 6.8.2 (with -fglasgow-exts) does not seem to accept this "exists"
> keyword? 

> Does a book or document already exist (except the website) that tells
> more about not standarized yet very cool Haskell thingies that make
> writing real world applications possible? I would LOVE such a book.

are you read GHC docs? its chapter 7 is all about language extensions and
also contains further references


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Yi and Data.ByteString

2008-01-22 Thread Bulat Ziganshin
Hello gwern0,

Monday, January 21, 2008, 10:18:15 PM, you wrote:

> really built-in - they're a separate library. You could perhaps
> suggest that [Char] could be often optimized into ByteString
> operations but then ByteStrings need to either lose their library
> status and be incorporated into GHC

it is no problem, although it should be done in a bit different way.
some concrete version of ByteString library should be built-in into
GHC (base library, probably) and used *only* for this purpose while
ByteString library by itself should remain separate and continue to
improve

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Duncan Coutts

On Tue, 2008-01-22 at 13:48 +0100, Henning Thielemann wrote:
> On Tue, 22 Jan 2008, Duncan Coutts wrote:
> 
> > > At the time I thought that the encoding (in my case UTF-8) was “leaking
> > > through”.  After switching to GHC 6.8 the behaviour seems to have
> > > changed, and mapping 'ord' on a string results in a list of ints
> > > representing the Unicode code point rather than the encoding:
> >
> > Yes. GHC 6.8 treats .hs files as UTF-8 where it previously treated them
> > as Latin-1.
> 
> Can this be controlled by an option?

>From the GHC manual:

GHC assumes that source files are ASCII or UTF-8 only, other
encodings are not recognised. However, invalid UTF-8 sequences
will be ignored in comments, so it is possible to use other
encodings such as Latin-1, as long as the non-comment source
code is ASCII only.

There is no option to have GHC assume a different encoding. You can use
something like iconv to convert .hs files from another encoding into
UTF-8.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Henning Thielemann

On Tue, 22 Jan 2008, Duncan Coutts wrote:

> > At the time I thought that the encoding (in my case UTF-8) was “leaking
> > through”.  After switching to GHC 6.8 the behaviour seems to have
> > changed, and mapping 'ord' on a string results in a list of ints
> > representing the Unicode code point rather than the encoding:
>
> Yes. GHC 6.8 treats .hs files as UTF-8 where it previously treated them
> as Latin-1.

Can this be controlled by an option?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Announce: mersenne-random 0.1, very fast pseudo-random number generation for Haskell

2008-01-22 Thread Yitzchak Gale
Don Stewart wrote:
> I'm pleased to announce the creation of the mersenne-random package,

Excellent! We were just discussing that.

> ...the implementation we bind to is heavily
> impure, so only a single generator is possible per-process (splitting
> generators is also not supported)...
> Note that the cpu isn't detected automatically, so to turn on SIMD flags
> for your cpu, you'll need to build it by hand

These are critical pieces of information. The only place I see them
is in this email. Perhaps you should add them to the description on
the Hackage page? Or at least to the README?

> Some light abstractions are implemented over the raw C interface, including
> a type class for SFMT-generated Haskell values, and lists of those values.

Haddocks for this?

Thanks,
Yitz
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Duncan Coutts

On Tue, 2008-01-22 at 12:56 +0300, Miguel Mitrofanov wrote:
> >   > chr . ord $ 'å'
> >   '\229'
> > What would I have to do to get an 'å' from '229'?
> 
> It seems you already have it; 'å' is the same as '\229'.

Yes.

>  But IO output is still 8-bit, so when you ask ghci to print 'å', you get 
> '\229'.

No. :-)

if you 'print' it you get:

print 'å'
= putStrLn (show 'å')
= putStrLn "\229"

this has nothing to do with 8-bit IO. It's just what 'show' does for
Char.

If you..
putStrLn "å"
then you do get the low 8 bits being printed. But that's not what is
going on above.

>  You can use utf-string library (from hackage).

import qualified Codec.Binary.UTF8.String as UTF8
putStrLn (UTF8.encodeString "å")

or just:

import qualified System.IO.UTF8
UTF8.putStrLn "å"


Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] non-alphabetical mathematical symbols as non-infix function names

2008-01-22 Thread Duncan Coutts

On Tue, 2008-01-22 at 07:03 +0100, Cetin Sert wrote:
> (¬) :: Bool → Bool
> (¬) q = not q
> 
> q = True
> ¬ q : parser error on input
> q ¬ : parser error (possibly incorrect indentation)
> (¬ q) : Couldn't match expected type `Bool -> t' against inferred type
> `Bool' In the expression: (� True) In the definition of `it': it = (�
> True) * 
> (q ¬) : False
> 
> (Why) is it not possible to define a (non-infix) function whose name
> consists of a single non-alphabetical mathematical symbol?

Haskell does not support user-defined unary prefix operators, only
infix. The only one is prefix negation -n.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Duncan Coutts

On Tue, 2008-01-22 at 09:29 +, Magnus Therning wrote:
> I vaguely remember that in GHC 6.6 code like this
> 
>   length $ map ord "a string"
> 
> being able able to generate a different answer than
> 
>   length "a string"

That seems unlikely.

> At the time I thought that the encoding (in my case UTF-8) was “leaking
> through”.  After switching to GHC 6.8 the behaviour seems to have
> changed, and mapping 'ord' on a string results in a list of ints
> representing the Unicode code point rather than the encoding:

Yes. GHC 6.8 treats .hs files as UTF-8 where it previously treated them
as Latin-1.

>   > map ord "åäö"
>   [229,228,246]
> 
> Is this the case, or is there something strange going on with character
> encodings?

That's what we'd expect. Note that GHCi still uses Latin-1. This will
change in GHC-6.10.

> I was hoping that this would mean that 'chr . ord' would basically be a
> no-op, but no such luck:
> 
>   > chr . ord $ 'å'
>   '\229'
> 
> What would I have to do to get an 'å' from '229'?

Easy!

Prelude> 'å' == '\229'
True
Prelude> 'å' == Char.chr 229
True

Remember, when you type:
Prelude> 'å'

what you really get is:
Prelude> putStrLn (show 'å')

So perhaps what is confusing you is the Show instance for Char which
converts Char -> String into a portable ascii representation.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hamming's Problem

2008-01-22 Thread Bertram Felgenhauer
I wrote:
>  merge' (x:xs) ys = x : merge xs ys
>
>  hammingx = 1 : foldr1 merge' [map (h x) hammingx | x <- hammingx]

Sorry. 'foldr1' is still slightly too strict. (Why doesn't the Haskell
report define foldr1 in terms of foldr?)

The code that works is

marge' [] ys = ys
merge' (x:xs) ys = x : merge xs ys

hammingx = 1 : foldr merge' [] [map (h x) hammingx | x <- hammingx]

I had tested that version, but I assumed the foldr1 version would
be equivalent.

>which actually works.

And I wrote that without testing. Shame on me.

Bertram
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Newbie question

2008-01-22 Thread Jon Fairbairn
Bulat Ziganshin <[EMAIL PROTECTED]> writes:

> Hello Jon,
>
> Monday, January 21, 2008, 9:28:09 PM, you wrote:
>
>>> Ok. I have a my own class "class A a" and want to write function like
>>> this  "f:: (A a)=>Integer->a". Can I do it?
>
>> But in general you are going to want something a bit more
>> useful, which means that you have to have a path from
>> Integer to a
>
> i.e. you should have other functions that produce A from Integer and
> at the last end this means that class A should provide some way to
> do it

I'm not sure we're using the same terminology. In the
example I gave, the class A doesn't provide anything from
Integer to a, unless defining an overloaded function outside
the class definition counts as the class providing something.

-- 
Jón Fairbairn [EMAIL PROTECTED]


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Miguel Mitrofanov
>   > chr . ord $ 'å'
>   '\229'
> What would I have to do to get an 'å' from '229'?

It seems you already have it; 'å' is the same as '\229'. But IO output is still 
8-bit, so when you ask ghci to print 'å', you get '\229'. You can use 
utf-string library (from hackage).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Felipe Lessa
2008/1/22 Magnus Therning <[EMAIL PROTECTED]>:
> I vaguely remember that in GHC 6.6 code like this
>
>   length $ map ord "a string"
>
> being able able to generate a different answer than
>
>   length "a string"

I guess it's not very difficult to prove that

 ∀ f xs.  length xs == length (map f xs)

even in the presence of seq.

-- 
Felipe.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Has character changed in GHC 6.8?

2008-01-22 Thread Magnus Therning
I vaguely remember that in GHC 6.6 code like this

  length $ map ord "a string"

being able able to generate a different answer than

  length "a string"

At the time I thought that the encoding (in my case UTF-8) was “leaking
through”.  After switching to GHC 6.8 the behaviour seems to have
changed, and mapping 'ord' on a string results in a list of ints
representing the Unicode code point rather than the encoding:

  > map ord "åäö"
  [229,228,246]

Is this the case, or is there something strange going on with character
encodings?

I was hoping that this would mean that 'chr . ord' would basically be a
no-op, but no such luck:

  > chr . ord $ 'å'
  '\229'

What would I have to do to get an 'å' from '229'?

/M

-- 
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus@therning.org Jabber: magnus.therning@gmail.com
http://therning.org/magnus

What if I don't want to obey the laws? Do they throw me in jail with
the other bad monads?
 -- Daveman



signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe