Re: [Haskell-cafe] (a - [b]) vs. [a - b]
Chad Scherrer wrote: Are (a - [b]) and [a - b] isomorphic? I'm trying to construct a function f :: (a - [b]) - [a - b] that is the (at least one-sided) inverse of f' :: [a - b] - a - [b] f' gs x = map ($ x) gs Anything better than this? f g = [\x - g x !! n | n - [0..]] -Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Boost equivalent
On 01/02/07, Slavomir Kaslev [EMAIL PROTECTED] wrote: Even sweeter is easily accessing .Net Framework from ghc, especially for Windows users. .Net Framework is huge. It is de-facto _the_ windows framework. Are there any projects going in this direction? That would indeed be nice - it would make a good replacement for the old H/Direct COM interface, which sadly no longer seems to be maintained... You might also be interested in a couple of Haskell for .NET projects: http://galois.com/~sof/hugs98.net/ (Hugs.NET) http://kahu.zoot.net.nz/ (Mondrian, includes Haskell.NET) http://php.cin.ufpe.br/~haskell/haskelldotnet/ (Haskell.NET) None seem maintained, unfortunately - the last URL is dead, which may be temporary... Paul. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Channel9 Interview: Software Composability andthe Future of Languages
Claus Reinke wrote: while (hGetBuf h buf bufsize == bufsize) crc := updateCrc crc buf bufsize break if crc==0 print crc inContT $ callCC $ \break - do flip execStateT 0 $ do whileM (liftM (== bufsize) (hGetBuf h buf bufsize)) $ do modifyM (updateCrc buf bufsize) crc - get when (crc == 0) (lift (break crc)) print crc first. it's longer than original. The above version required passing break explicitly. I can pack that into a Reader. The actual semantics of the while loop from 'c' are then more closely followed. This allows: run_ = runner_ testWhile_ runner_ m = runRWS (runContT m return) NoExit_ (17::Int) testWhile_ = while_ (liftM (10) get) innerWhile_ innerWhile_ = do v - get tell_ [show v] when' (v==20) (tell_ [breaking] breakW_) if v == 15 then put 30 continueW_ else modify pred The result is ((),20,[17,16,15,30,29,28,27,26,25,24,23,22,21,20,breaking]) Where there is the benefit over C of putting the break or continue in a sub-function. The full code (for two versions) is: -- By Chris Kuklewicz, BSD-3 license, February 2007 -- Example of pure while and repeat until looping constructs using -- the monad transformer library. Works for me in GHC 6.6 -- -- The underscore version is ContT of RWS and this works more -- correctly than the non-underscore version of RWST of Cont. -- -- Perhaps Monad Cont done right from the wiki would help? import Control.Monad.Cont import Control.Monad.RWS import Control.Monad.Error import Control.Monad.ST import System.IO.Unsafe import Data.STRef -- Note that all run* values are the same Type main = mapM_ print [run,run2,run_,run2_] run,run_,run2,run2_ :: MyRet () run = runner testWhile run2 = runner testRepeatUntil run_ = runner_ testWhile_ run2_ = runner_ testRepeatUntil_ runner_ m = runRWS (runContT m return) NoExit_ (17::Int) runner m = (flip runCont) id (runRWST m NoExit (17)) testRepeatUntil_ = repeatUntil_ (liftM (==17) get) innerRepeatUntil_ testRepeatUntil = repeatUntil (liftM (==17) get) innerRepeatUntil innerRepeatUntil_ = tell_ [I ran] breakW_ innerRepeatUntil = tell [I ran] breakW testWhile_ = while_ (liftM (10) get) innerWhile_ testWhile = while (liftM (10) get) innerWhile -- innerWhile_ :: ContT () (T_ (Exit_ () Bool Bool)) () innerWhile_ = do v - get tell_ [show v] when' (v==20) (tell_ [breaking] breakW_) if v == 15 then put 30 continueW_ else modify pred innerWhile = do v - get tell [show v] when' (v==20) (tell [breaking] breakW) if v == 15 then put 30 continueW else modify pred -- The Monoid restictions means I can't write an instance, so use tell_ tell_ = lift . tell -- Generic defintions getCC :: MonadCont m = m (m a) getCC = callCC (\c - let x = c x in return x) getCC' :: MonadCont m = a - m (a, a - m b) getCC' x0 = callCC (\c - let f x = c (x, f) in return (x0, f)) when' :: (Monad m) = Bool - m a - m () when' b m = if b then (m return ()) else return () -- Common types type MyState = Int type MyWriter = [String] type MyRet a = (a,MyState,MyWriter) -- RWST of Cont Types type T r = RWST r MyWriter MyState type Foo r a = T (Exit (MyRet r) a a) (Cont (MyRet r)) type WhileFunc = Foo () Bool type ExitFoo r a = Foo r a a -- (Exit r a a) (Cont r) a type ExitType r a = T (Exit r a a) (Cont r) a data Exit r a b = Exit (a - ExitType r b) | NoExit -- ContT of RWS Types type T_ r = RWS r MyWriter MyState type ExitType_ r a = ContT r (T_ (Exit_ r a a)) a data Exit_ r a b = Exit_ (a - ExitType_ r b) | NoExit_ -- Smart destructor for Exit* types getExit (Exit loop) = loop getExit NoExit = (\ _ - return (error NoExit)) getExit_ (Exit_ loop) = loop getExit_ NoExit_ = (\ _ - return (error NoExit)) -- I cannot see how to lift withRWS, so use local -- Perhaps Monad Cont done right from the wiki would help? withLoop_ loop = local (\r - Exit_ loop) -- withRWST can change the reader Type withLoop loop = withRWST (\r s - (Exit loop,s)) -- The condition is never run in the scope of the (withLoop loop) -- continuation. I could have invoked (loop True) for normal looping -- but I decided a tail call works as well. This decision has -- implication for the non-underscore version, since the writer/state -- can get lost if you call (loop _). while_ mCondition mBody = do (proceed,loop) - getCC' True let go = do check -mCondition when' check (withLoop_ loop mBody go) when' proceed go while mCondition mBody = do (proceed,loop) - getCC' True let go = do check -mCondition when' check (withLoop loop mBody go) when' proceed go repeatUntil_ mCondition mBody = do (proceed,loop) - getCC' True let go = do withLoop_ loop mBody check - mCondition when' (not check) go when' proceed go repeatUntil mCondition mBody = do (proceed,loop) - getCC' True let go = do withLoop loop mBody check -
[Haskell-cafe] Re: Let's welcome the Ruby hackers!
Alexis wrote: In contrast with other IT-related communities i've experienced, i've found the Haskell community (both here and on IRC) to generally be helpful, good-humoured and mercifully lacking in flames and alpha behaviours. :-) I have to reject this claim because there are quite many alphas in here. For instance, ∀α.α notoriously tries to creep in every discussion, just because he thinks that he is principally more general than the others. Of course, he's a blatant liar. Another well known troll is ∀α.α - α. While at least not throwing in contradictory posts, he greatly overestimates his role. Most often, you can just elide his contributions as he only repeats prior arguments. Sometimes, he even signs his posts with the pseudonym (∀α.α - α)-(∀α.α - α) to rise in rank, but this is easily seen through. The list once tried to employ alpha-conversion to get rid of them. But the only effect was that now, the betas annoy us as well! A particularly persistent offspring is ∀α.α - β - β giving rise to much debate in regular intervals: he managed to subvert parametricity. Also, the mischievous ∀αβ.α - β even plotted with evil IO to get the attention he thinks he deserves. In the end, the alphas and betas are noisy braggarts, talking very long about what they want to do without doing anything at all. It's the lambdas who do all the real work. Fortunately, they most often don't need the signature from their alpha bosses. Regards, apfelmus PS: This mail is best viewed with Unicode (UTF-8). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] snd and tuples of various sizes...
On Thu, 2007-02-01 at 21:01 -1000, Tim Newsham wrote: instance Second [a] a where snd [] = error don't got none snd (x:y:xs) = y Would'nt that instance mean this: snd [] produces error snd [x] gives [] I'd implement it something like this (if this works?): instance Second [a] (Maybe a) where snd [] = Nothing snd [x] = Nothing snd (x:y:xs) = Just y signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] snd and tuples of various sizes...
Mattias Bengtsson wrote: On Thu, 2007-02-01 at 21:01 -1000, Tim Newsham wrote: instance Second [a] a where snd [] = error don't got none snd (x:y:xs) = y Would'nt that instance mean this: snd [] produces error snd [x] gives [] I'd implement it something like this (if this works?): instance Second [a] (Maybe a) where snd [] = Nothing snd [x] = Nothing snd (x:y:xs) = Just y And while we're re-implementing the Prelude with MPTC: class Currying a b | a - b where curryC :: a - b uncurryC :: b - a instance Currying ((a, b) - c) (a - b - c) where curryC = curry uncurryC = uncurry instance Currying ((a, b, c) - d) (a - b - c - d) where curryC f a b c = f (a, b, c) uncurryC f (a, b, c) = f a b c instance Currying ((a, b, c, d) - e) (a - b - c - d - e) where curryC f a b c d = f (a, b, c, d) uncurryC f (a, b, c, d) = f a b c d instance Currying ((a, b, c, d, e) - f) (a - b - c - d - e - f) where curryC f a b c d e = f (a, b, c, d, e) uncurryC f (a, b, c, d, e) = f a b c d e ... Andreas -- some cannot be created more equal than others ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Array copy performance
Hi, I am trying to improve the memory usage of regex-tdfa and I wanted to ask an array question. If I have two identical STUArrays (same type and bounds) then what is the most efficient way to overwrite the data in the destination with the data in the source? Does this work for STArrays? Is there a GHC only solution? Is there a way to avoid the long loop? forM_ (range b) $ \index - readArray source index = writeArray destination index Is Data.Array.Storable the only route? I do not think Data.Array.Diff will work well since I have one source going to multiple destinations, each with a few different changes. -- Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: Takusen 0.6
We are pleased to announce a new release of Takusen. There are a large number of changes and bug-fixes: - Oracle support for processing cursors returned from procedure calls - withContinuedSession supports connection reuse (e.g. for persistent connections and connection pooling) - new README file with useful information about getting started with Takusen - new UTF8 en/de-coder (the old one was buggy) - PostgreSQL support for CalendarTime - improved Cabal Setup.hs script, which does a better job of modifying the installation to reflect installed DBMS's. This gives good ghci support (PostgreSQL users on Windows have a small extra step) - prepared statement API requires that users distinguish between queries and DML Our long-term plans are the same as ever: - large objects - ODBC and MS Sql Server backends Release: http://darcs.haskell.org/takusen/takusen-0.6.tar.gz Source: darcs get --partial http://darcs.haskell.org/takusen Oleg and Alistair ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: snd and tuples of various sizes...
Mattias == Mattias Bengtsson [EMAIL PROTECTED] writes: Mattias On Thu, 2007-02-01 at 21:01 -1000, Tim Newsham wrote: instance Second [a] a where snd [] = error don't got none snd (x:y:xs) = y Mattias Would'nt that instance mean this: snd [] produces error Mattias snd [x] gives [] No. It is non-exhaustive pattern. In fact this is needed: instance Second [a] a where snd (_:y:_) = y snd _ = error don't got none Mattias I'd implement it something like this (if this works?): Mattias instance Second [a] (Maybe a) where snd [] = Nothing snd Mattias [x] = Nothing snd (x:y:xs) = Just y Well, we also can define: class SafeSecond a b | a - b where ssnd :: (Monad m) = a - m b instance SafeSecond [a] a where ssnd (_:y:_) = return y ssnd _ = fail don't got none main = do print $ (ssnd [1, 2, 3] :: Maybe Int) print $ (ssnd [1] :: Maybe Int) -- WBR, Max Vasin. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Timezone Database Library
Hello, is there a haskell library that provides facilities to read and use the tzfile format [1], or equivalent in Windows? TIA Martin [1] http://www.twinsun.com/tz/tz-link.htm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Array copy performance
Hello Chris, Friday, February 2, 2007, 4:44:37 PM, you wrote: If I have two identical STUArrays (same type and bounds) then what is the most efficient way to overwrite the data in the destination with the data in the source? Does this work for STArrays? Is there a way to avoid the long loop? forM_ (range b) $ \index - readArray source index = writeArray destination index the topic of efficient looping over arrays is briefly covered in http://haskell.org/haskellwiki/Modern_array_libraries Is there a GHC only solution? yes, use unsafeCoerce# memcpy: module Data.Array.Base where ... #ifdef __GLASGOW_HASKELL__ thawSTUArray :: Ix i = UArray i e - ST s (STUArray s i e) thawSTUArray (UArray l u arr#) = ST $ \s1# - case sizeofByteArray# arr# of { n# - case newByteArray# n# s1# of { (# s2#, marr# #) - case unsafeCoerce# memcpy marr# arr# n# s2# of { (# s3#, () #) - (# s3#, STUArray l u marr# #) }}} foreign import ccall unsafe memcpy memcpy :: MutableByteArray# RealWorld - ByteArray# - Int# - IO () #endif /* __GLASGOW_HASKELL__ */ -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] A distributed and replicating native Haskell database
Folks, Allegro Common Lisp has AllegroCache [1], a database built on B-Trees that lets one store Lisp objects of any type. You can designate certain slots (object fields) as key and use them for lookup. ACL used to come bundled with the ObjectStore OODBMS for the same purpose but then adopted a native solution. AllegroCache is not distributed or replicating but supports automatic versioning. You can redefine a class and new code will store more (or less) data in the database while code that uses the old schema will merrily chug along. Erlang [2] has Mnesia [3] which lets you store any Erlang term (object). It stores records (tuples, actually) and you can also designate key fields and use them for lookup. I haven't looked into this deeply but Mnesia is built on top of DETS (Disk-based Term Storage) which most likely also uses a form of B-Trees. Mnesia is distributed and replicated in real-time. There's no automatic versioning with Mnesia but user code can be run to read old records and write new ones. Would it make sense to build a similar type of a database for Haskell? I can immediately see how versioning would be much harder as Haskell is statically typed. I would love to extend recent gains in binary serialization, though, to add indexing of records based on a designated key, distribution and real-time replication. What do you think? To stimulate discussion I would like to ask a couple of pointed questions: - How would you designate a key for a Haskell data structure? - Is the concept of a schema applicable to Haskell? Thanks, Joel [1] http://franz.com/products/allegrocache/index.lhtml [2] http://erlang.org/faq/t1.html [3] http://erlang.org/faq/x1409.html -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Array copy performance
On Fri, 2007-02-02 at 17:02 +0300, Bulat Ziganshin wrote: Hello Chris, Friday, February 2, 2007, 4:44:37 PM, you wrote: If I have two identical STUArrays (same type and bounds) then what is the most efficient way to overwrite the data in the destination with the data in the source? Does this work for STArrays? Is there a way to avoid the long loop? forM_ (range b) $ \index - readArray source index = writeArray destination index the topic of efficient looping over arrays is briefly covered in http://haskell.org/haskellwiki/Modern_array_libraries I should note that it is possible to generate good loops, though it's not easy yet from high level code. The binary package has a memory throughput benchmark which compares C and Haskell byte/word read/write loops: http://darcs.haskell.org/binary/tests/ All the Haskell versions compile down to good loops, though the loop body is bigger than in the C case (take a look at the assembly output for the -fasm route). However that's enough for the Haskell versions to get a significant fraction of the memory throughput of the C versions: C memory throughput benchmarks: 500MB of bytes written in 0.468s, at: 1068.3MB/s 500MB of bytes readin 0.380s, at: 1315.7MB/s 500MB of words written in 0.376s, at: 1329.7MB/s 500MB of words readin 0.192s, at: 2604.0MB/s Haskell memory throughput benchmarks: 500MB of bytes written in 1.560s, at: 320.5MB/s 500MB of bytes readin 2.192s, at: 228.1MB/s 500MB of words written in 0.340s, at: 1470.5MB/s 500MB of words readin 0.344s, at: 1453.4MB/s As you can see, the extra size of the loop body hurts us more in the byte size cases than in the word size one, where we're getting much closer to saturating the memory bandwidth of the box. It's a 64bit box so the words are 8 bytes. I'm not quite sure what is going on in the words written case. Perhaps someone can see why the C one is loosing out to the Haskell version. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A distributed and replicating native Haskell database
Joel Reymont wrote: Folks, Allegro Common Lisp has AllegroCache [1], a database built on B-Trees that lets one store Lisp objects of any type. You can designate certain slots (object fields) as key and use them for lookup. ACL used to come bundled with the ObjectStore OODBMS for the same purpose but then adopted a native solution. AllegroCache is not distributed or replicating but supports automatic versioning. You can redefine a class and new code will store more (or less) data in the database while code that uses the old schema will merrily chug along. That implies being able to put persistent code into the database. Easy enough in Lisp, less easy in Haskell. How do you serialize it? As a rule, storing functions along with data is a can of worms. Either you actually store the code as a BLOB or you store a pointer to the function in memory. Either way you run into problems when you upgrade your software and expect the stored functions to work in the new context. Erlang [2] has Mnesia [3] which lets you store any Erlang term (object). It stores records (tuples, actually) and you can also designate key fields and use them for lookup. I haven't looked into this deeply but Mnesia is built on top of DETS (Disk-based Term Storage) which most likely also uses a form of B-Trees. Erlang also has a very disciplined approach to code updates, which presumably helps a lot when functions are stored. Mnesia is distributed and replicated in real-time. There's no automatic versioning with Mnesia but user code can be run to read old records and write new ones. Would it make sense to build a similar type of a database for Haskell? I can immediately see how versioning would be much harder as Haskell is statically typed. I would love to extend recent gains in binary serialization, though, to add indexing of records based on a designated key, distribution and real-time replication. I very much admire Mnesia, even though I'm not an Erlang programmer. It would indeed be really cool to have something like that. But Mnesia is built on the Erlang OTP middleware. I would suggest that Haskell needs a middleware with the same sort of capabilities first. Then we can build a database on top of it. What do you think? To stimulate discussion I would like to ask a couple of pointed questions: - How would you designate a key for a Haskell data structure? I haven't tried compiling it, but something like: class (Ord k) = DataKey a k | a - k where keyValue :: a - k - Is the concept of a schema applicable to Haskell? The real headache is type safety. Erlang is entirely dynamically typed, so untyped schemas with column values looked up by name at run-time fit right in, and its up to the programmer to manage schema and code evolution to prevent errors. Doing all this in a statically type safe way is another layer of complexity and checking. Actually this is also just another special case of the middleware case. If we have two processes, A and B, that need to communicate then they need to agree on a protocol. Part of that protocol is the data types. If B is a database then this reduces to the schema problem. So lets look at the more general problem first and see if we can solve that. There are roughly two ways for A and B to agree on the protocol. One is to implement the protocol separately in A and B. If it is done correctly then they will work together. But this is not statically checkable (ignoring state machines and model checking for now). This is the Erlang approach, because dynamic checking is the Erlang philosophy. Alternatively the protocol can be defined in a special purpose protocol module P, and A and B then import P. This is the approach taken by CORBA with IDL. However what happens if P is updated to P'? Does this mean that both A and B need to be recompiled and restarted simultaneously? Requiring this is a Bad Thing; imagine if every bank in the world had to upgrade and restart its computers simultaneously in order to upgrade a common protocol. (This protocol versioning problem was one of the major headaches with CORBA.) We would have to have P and P', live simultaneously, and processes negotiate the latest version of the protocol that they both support when they start talking. That way the introduction of P' does not need to be simultaneous with the withdrawal of P. There is still the possibility of a run-time failure at the protocol negotiation stage of course, if it transpires that the to processes have no common protocol. So we need a DSL which allows the definition of data types and abstract protocols (i.e. who sends what to whom when) that can be imported by the two processes (do we need N-way protocols?) on each end of the link. If we could embed this in Haskell directly then so much the better, but something that needs preprocessing would be fine too. However there is a wrinkle here: what about pass through processes which don't
Re: [Haskell-cafe] A distributed and replicating native Haskell database
On Feb 2, 2007, at 3:06 PM, Paul Johnson wrote: As a rule, storing functions along with data is a can of worms. Either you actually store the code as a BLOB or you store a pointer to the function in memory. Either way you run into problems when you upgrade your software and expect the stored functions to work in the new context. ACache does not store code in the database. You cannot read the database unless you have your original class code. ACache may store the schema, i.e. the parent class names, slot names, etc. Erlang also has a very disciplined approach to code updates, which presumably helps a lot when functions are stored. No storing of code here either. What you store in Erlang is just tuples so there's no schema or class definition. No functions are stored since any Erlang code can fetch the tuples from Mnesia. You do need to have the original record definition around but this is just to be able to refer to tuple elements with field names rather name field position. I very much admire Mnesia, even though I'm not an Erlang programmer. It would indeed be really cool to have something like that. But Mnesia is built on the Erlang OTP middleware. I would suggest that Haskell needs a middleware with the same sort of capabilities first. Then we can build a database on top of it. Right. That would be a prerequisite. The real headache is type safety. Erlang is entirely dynamically typed, so untyped schemas with column values looked up by name at run-time fit right in, and its up to the programmer to manage schema and code evolution to prevent errors. Doing all this in a statically type safe way is another layer of complexity and checking. I believe Lambdabot does schema evolution. Alternatively the protocol can be defined in a special purpose protocol module P, and A and B then import P. This is the approach taken by CORBA with IDL. However what happens if P is updated to P'? Does this mean that both A and B need to be recompiled and restarted simultaneously? Requiring this is a Bad Thing; imagine if every bank in the world had to upgrade and restart its computers simultaneously in order to upgrade a common protocol. I would go for the middle ground and dump the issue entirely. Lets be practical here. When a binary protocol is updated, all code using the protocol needs to be updated. This would be good enough. It would suite me just fine too as I'm not yearning for CORBA, I just want to build a trading infrastructure entirely in Haskell. There is still the possibility of a run-time failure at the protocol negotiation stage of course, if it transpires that the to processes have no common protocol. So no protocol negotiation! However there is a wrinkle here: what about pass through processes which don't interpret the data but just store and forward it. Various forms of protocol adapter fit this scenario, as does the database you originally asked about. Any packet traveling over the wire would need to have a size, followed by a body. Any pass-through protocol can just take the binary blob and re-send it. Thanks, Joel -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Boost equivalent
On 2/1/07, Slavomir Kaslev [EMAIL PROTECTED] wrote: would be sweet. Even sweeter is easily accessing .Net Framework from ghc, especially for Windows users. .Net Framework is huge. It is de-facto _the_ windows framework. Are there any projects going in this direction? I would so love to see this happen. I'm actually surprised it hasn't, considering the GHC guy works for MS! If for nothing else, .NET has an excellent GUI in Windows Forms. Manipulating that from Haskell would be a dream come true! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Become a GHC build slave!
Thanks largely to Ian Lynagh, GHC now has a BuildBot infrastructure to automate nightly builds on multiple platforms. This replaces the old set of shell scripts that we used to run nightly builds; now adding new clients to the setup is relatively easy, instructions are here: http://hackage.haskell.org/trac/ghc/wiki/BuildBot So far we have various Windows builds running, and I'll be moving over the existing Linux nightly builds in due course. If you have a spare machine or a machine that is idle overnight, and you'd like to use it to run automated GHC builds, then please take a look at the above page for how to get started. We especially need platforms that we don't use regularly (i.e. not Windows or Linux/x86/x86_64). Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (a - [b]) vs. [a - b]
Oops, I thought I had sent a response to the cafe, but it looks like it just went to Matthew. Unfortunately, I was trying to give a simplification of the real problem, where the monad is STM instead of []. Based on apfelmus's observation of why they can't be isomorphic, I'm guessing I'm out of luck. http://www.haskell.org/pipermail/haskell-cafe/2006-December/020041.html So in reality, I'm trying to construct something like f :: (a - STM b) - STM (a - b) I just figured it was a general monadic kind of problem, more simply expressed using lists. But the (!!) solution doesn't make sense in this context. On 2/2/07, Yitzchak Gale [EMAIL PROTECTED] wrote: Chad Scherrer wrote: Are (a - [b]) and [a - b] isomorphic? I'm trying to construct a function f :: (a - [b]) - [a - b] that is the (at least one-sided) inverse of f' :: [a - b] - a - [b] f' gs x = map ($ x) gs Anything better than this? f g = [\x - g x !! n | n - [0..]] -Yitz -- 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] strict bytestring fun
Donald Bruce Stewart wrote: High performance strings on the shootout: http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcollang=all interesting alternative programs 0.5 Haskell GHC #5 1.2990,880270 1.0 Clean 2.77600 136 [snip] Ah well, its illegally strict, but its good to know you can do it, eh? (A lazy bytestring version has been submitted, we'll see how that runs). Hmm, apparently it's a factor of 10 slower. Using unsafeHead and unsafeTail in the strict bytestring version is a *very* big win. Without that it'd be a more reasonable factor of about 2 between the lazy and the strict bytestring versions, according to my own tests. FWIW, the more natural {-# OPTIONS -O -fbang-patterns #-} import qualified Data.ByteString.Lazy.Char8 as B main = print . loop 0 = B.getContents loop !s !xs = case B.readInt xs of Just (n, xs') - loop (s+n) (B.tail xs') -- drop the newline Nothing - s runs slightly faster than the explicit parsing done by the current lazy bytestring entry in my tests. Bertram ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Become a GHC build slave!
On Fri, Feb 02, 2007 at 04:37:41PM +, Simon Marlow wrote: Thanks largely to Ian Lynagh, GHC now has a BuildBot infrastructure to automate nightly builds on multiple platforms. This replaces the old set of shell scripts that we used to run nightly builds; now adding new clients to the setup is relatively easy, instructions are here: http://hackage.haskell.org/trac/ghc/wiki/BuildBot So far we have various Windows builds running, and I'll be moving over the existing Linux nightly builds in due course. If you have a spare machine or a machine that is idle overnight, and you'd like to use it to run automated GHC builds, then please take a look at the above page for how to get started. We especially need platforms that we don't use regularly (i.e. not Windows or Linux/x86/x86_64). Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Here at [EMAIL PROTECTED] we have the following that we could use: AIX on PPC Linux on PPC Mac OSX on PPC Mac OSX on x86 OpenVMS on Alpha Solaris on Sparc If needed we could also set up the following: Solaris on x86 BeOS on BeBox IRIX on MIPS Linux on Sparc something on Itanium (Preproduciton-caliber Float support) Also if you would like different version of windows we have: 2003 sever Vista -- Dennis Griffith, [EMAIL PROTECTED] Treasurer ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Write Yourself a Scheme in 48 Hours
On 2/1/07, Bryan O'Sullivan [EMAIL PROTECTED] wrote: Shannon -jj Behrens wrote: I'm going through the Write Yourself a Scheme in 48 Hours http://halogen.note.amherst.edu/~jdtang/scheme_in_48/tutorial/overview.html tutorial. I like it a lot, but I have some concerns. Are the exercises in the tutorial known to be solvable by mere mortals? The answer seems to be yes, iff the mortals in question have grasped the basics of monads, so they can fill in the gaps in the exposition. For instance: Rewrite parseNumber using...explicit sequencing with the = operator http://halogen.note.amherst.edu/~jdtang/scheme_in_48/tutorial/parser.html#symbols There aren't any examples of using = previous to this question. There's a peculiar mixture of assumptions in the article. He treats monads breezily, as if they're a given; but pattern matching (much more basic) receives some rather more detailed exposition. And he glosses over , but doesn't mention the rewrite rule from a-x to x=\a-. So don't beat yourself up. The tutorial is missing a few bits and pieces. Thanks. That's all I needed to hear :) -- http://jjinux.blogspot.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (a - [b]) vs. [a - b]
Uh, apologies. I got confused between reading your post and playing for a while, and answered the wrong question. /g On 2/2/07, J. Garrett Morris [EMAIL PROTECTED] wrote: On 2/2/07, Chad Scherrer [EMAIL PROTECTED] wrote: So in reality, I'm trying to construct something like f :: (a - STM b) - STM (a - b) I just figured it was a general monadic kind of problem, more simply expressed using lists. But the (!!) solution doesn't make sense in this context. Perhaps this will work for you: f x = join . liftM f This typechecks, and seems to work as expected, e.g.: Prelude Control.Concurrent.STM Control.Monad atomically (f readTVar (newTVar 'a')) 'a' /g -- It is myself I have never met, whose face is pasted on the underside of my mind. -- It is myself I have never met, whose face is pasted on the underside of my mind. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Levels of recursion
On 1/31/07, Andrew Wagner [EMAIL PROTECTED] wrote: So, a couple of questions to ponder about this: Is this unique to Haskell, or could the same be said about any functional language? How can we teach this better to newbies? Most of what I see in the tutorials is Higher order functions accept as parameters and/or return other functions. Here's some examples: explanation of map, explanation of foldr. Moving on, ... But clearly, this is something important, and I think we can do a better job of teaching it. Suggestions? The first time I really thought about this much was after reading Meijer, Fokkinga and Patterson's Functional Programming with Bananas, Lenses and Barbed Wire, which makes the comparison between arbitrary recursion and goto early on, and develops four replacement operators (cata-, ana-, hylo-, and paramorphisms). At the time, I was involved in teaching an introduction FP class in which we frequently discovered that students would latch onto primitive recursion early in the course and never stop using it, even as their functions became more convoluted and using maps and filters correspondingly easier. My natural thought was to wonder if the beginning of the course could be rewritten without primitive recursion, only introducing it later after the students were already comfortable with the higher-order combinators. Sadly, that never went anywhere. I'd be interested in hearing if anybody else got farther in attempting that teaching technique. /g -- It is myself I have never met, whose face is pasted on the underside of my mind. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How did you stumble on Haskell?
On 1/28/07, Alexy Khrabrov [EMAIL PROTECTED] wrote: How do people stumble on Haskell? My story isn't as interesting as some of these. My first quarter in school, I took a course taught in Scheme. I expressed some dissatisfaction with the lack of types (and, in particular, the collection of bugs that would have been easily caught with one), and the grad TA pointed me to ML. Some time later, I was talking to another prof. in the hall about ML, and an older guy walking by suggested that I was wasting my time and should go learn Haskell. At the time, the most obvious tutorial was the Gentle Introduction, which left me confused for about a year or so, but eventually (and I have no memory the trigger), I started writing code in Haskell and was completely hooked. (Incidentally, I eventually found out who the older guy was - Doug McIlroy - and he ended up advising my honors work. All in all, a very convenient meeting.) /g ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] It matters how Type Synonyms are defined?
Today, I was plugging away on a program and I ran into a problem. It seems that ErrorT can or can not take a type synonym as its monad, depending on how the type synonym was defined. For example, consider this GHCi interactive run: :k Maybe Maybe :: * - * let { a :: ErrorT String Maybe Bool; a = undefined } :t a a :: ErrorT String Maybe Bool :k State (Scope VVar) State (Scope VVar) :: * - * let { a :: ErrorT String (State (Scope VVar)) Bool; a = undefined } :t a a :: ErrorT String (State (Scope VVar)) Bool ScopeState is defined in a file as: type ScopeState a = State (Scope VVar) a :k ScopeState ScopeState :: * - * let { a :: ErrorT String ScopeState Bool; a = undefined } interactive:1:6: Type synonym `ScopeState' should have 1 argument, but has been given 0 In the type signature: a :: ErrorT String ScopeState Bool Now, I was going to ask something like, How can I define my type synonym so I can do this, but I figured out while writing this email that if I define ScopeState a different way: type ScopeState = State (Scope VVar) :k ScopeState ScopeState :: * - * let { a :: ErrorT String ScopeState Bool; a = undefined } :t a a :: ErrorT String ScopeState Bool So, my new question is: Why does it matter how ScopeState is defined? Bryan Burgers ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] It matters how Type Synonyms are defined?
Type synonyms are like type level functions. So long as they are fully applied, the type checker can treat them like macros, and expand them at compile time. But if they are only partially applied, it can't. Allowing full functions at the type level makes type inference practically impossible, so it's banned. In your case, the definition type T = S Int and type T a = S Int a might reasonably be considered equivalent, since eta reduction can turn the latter into the former. GHC could do automatic eta reduction, but people don't write such type synonyms very much (I think), so it doesn't. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of | Bryan Burgers | Sent: 02 February 2007 22:18 | To: haskell-cafe@haskell.org | Subject: [Haskell-cafe] It matters how Type Synonyms are defined? | | Today, I was plugging away on a program and I ran into a problem. It | seems that ErrorT can or can not take a type synonym as its monad, | depending on how the type synonym was defined. For example, consider | this GHCi interactive run: | | :k Maybe | Maybe :: * - * | let { a :: ErrorT String Maybe Bool; a = undefined } | :t a | a :: ErrorT String Maybe Bool | | :k State (Scope VVar) | State (Scope VVar) :: * - * | let { a :: ErrorT String (State (Scope VVar)) Bool; a = undefined } | :t a | a :: ErrorT String (State (Scope VVar)) Bool | | ScopeState is defined in a file as: | type ScopeState a = State (Scope VVar) a | | :k ScopeState | ScopeState :: * - * | let { a :: ErrorT String ScopeState Bool; a = undefined } | | interactive:1:6: | Type synonym `ScopeState' should have 1 argument, but has been given 0 | In the type signature: a :: ErrorT String ScopeState Bool | | Now, I was going to ask something like, How can I define my type | synonym so I can do this, but I figured out while writing this email | that if I define ScopeState a different way: | type ScopeState = State (Scope VVar) | | :k ScopeState | ScopeState :: * - * | let { a :: ErrorT String ScopeState Bool; a = undefined } | :t a | a :: ErrorT String ScopeState Bool | | So, my new question is: Why does it matter how ScopeState is defined? | | Bryan Burgers | ___ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | 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] It matters how Type Synonyms are defined?
On Fri, Feb 02, 2007 at 04:18:19PM -0600, Bryan Burgers wrote: Now, I was going to ask something like, How can I define my type synonym so I can do this, but I figured out while writing this email that if I define ScopeState a different way: type ScopeState = State (Scope VVar) this is off-topic, but this is a perfect example of where newtype deriving is great. newtype ScopeState a = ScopeState (State (Scope VVar) a) deriving(Monad,Functor,State (Scope VVar)) I just really like this idiom is all. Using it pervasively pays off greatly. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How did you stumble on Haskell?
On 1/28/07, Alexy Khrabrov [EMAIL PROTECTED] wrote: How do people stumble on Haskell? I was thinking that my story wasn't particularly interesting, but then again, I may be the only person on this list who can actually give a properly-cited publication as an answer to the question how did you learn Haskell?: Patricia Johann and Franklyn Turbak, Lumberjack Summer Camp: A Cross-Institutional Undergraduate Research Experience in Computer Science, Computer Science Education 11(4), Dec. 2001. - http://cs.wellesley.edu/~fturbak/pubs/cse01.pdf The shorter answer is, I got paid to learn it, when I was an undergrad, and so I find those of you with real jobs and real lives who learn new languages in their copious free time with no particular extrinsic motivation for it to be particularly admirable. Cheers, Kirsten -- Kirsten Chevalier* [EMAIL PROTECTED] *Often in error, never in doubt Relax. I'm weird, not violent.--Brad Boesen, _Disturbed_ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Suggestions for a hReadUntilStr implementation
Hey there, A few weeks back I was thinking of writing a Haskell program that automated a telnet session. One function that could be useful is a hReadUntilStr - that is, a function that takes a Handle as an input source, a String to match, and a Num a as the number of seconds to wait before returning a (String, Bool) where the String is all the text read from the Handle until either matching or timing out and the Bool is true if the input String was matched. Something like: hReadUntilStr :: (Num a) = Handle - String - a - IO (String, Bool) Is this the wrong way to think about the problem? If so, how should it be handled? If not, any ideas on the implementation? Any advice is appreciated. Cheers, Matt ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Alternate instance Show (Maybe a)?
Hello list, Suppose I want show Nothing to return , and show (Just foo) return show foo. I don't seem to be able to. Looks like I either have to use some other function name, like `mShow', or have to import Prelude hiding Maybe, reimplement Maybe, write all the other useful instances (Functor, Monad) for it, etc. Not particularly hard, but looks ugly. Isn't there a better solution? I recall some discussion about this, but can't find it in the archives... TIA, -- DoubleF No virus detected in this message. Ehrm, wait a minute... /kernel: pid 56921 (antivirus), uid 32000: exited on signal 9 Oh yes, no virus:) pgpK6irUBjFEF.pgp Description: PGP signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] It matters how Type Synonyms are defined?
Agreed. I've written quite a bit of code that way myself. Looking at Iavor's monadLib, though, raised a question: has there been any consider of removing the requirement that the newtype be the last argument? The classes for state monads, etc. are rather backwards as it is, since the independent type (and the primary point of the class) is always written last. It seems like it should be equally easy to support something like: newtype Scopestate a = ScopeState (State (Scope VVar) a) deriving (Monad ScopeState, Functor ScopeState, StateM ScopeState (Scope VVar)) or even, ideally, a mixture of the two. /g On 2/2/07, John Meacham [EMAIL PROTECTED] wrote: On Fri, Feb 02, 2007 at 04:18:19PM -0600, Bryan Burgers wrote: Now, I was going to ask something like, How can I define my type synonym so I can do this, but I figured out while writing this email that if I define ScopeState a different way: type ScopeState = State (Scope VVar) this is off-topic, but this is a perfect example of where newtype deriving is great. newtype ScopeState a = ScopeState (State (Scope VVar) a) deriving(Monad,Functor,State (Scope VVar)) I just really like this idiom is all. Using it pervasively pays off greatly. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- It is myself I have never met, whose face is pasted on the underside of my mind. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe