Re: [Haskell-cafe] Parse error

2010-01-18 Thread Evan Laforge
 It's an improvement. It's still not pretty, but I guess that's as good as
 it's going to get...

 Maybe this is an instance of Haskell trying to tell me if you need to write
 a 20-line do-block in the middle of your function, you're doing it wrong.

20 lines is a lot, but I have smaller ones all the time.  You need 4
spaces of indent to continue a let.  Here's another way to understand
why:

f = do
let x = some big
expression
y = another big
expression
x y

If you wonder why multiple let syntax is needed, well I don't really
know for sure, but consider if x and y were mutually recursive.

I was annoyed at first with all the indentation but got used to it.  I
use 4 space indents so it works out ok.  Binding with - or in where
can reduce the indentation but is not always appropriate.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Takusen - reading from one db inserting into another

2010-01-18 Thread Michael Hartl
Don't know if you can have two connections, sounds difficult in regard
to the DBM monad. Only the deveolopers will know.

However, two obvious solutions come to my mind: 1) build a result set
and process it after returning from DBM or 2) use two separate threads
and send the queried data from your source db to the other thread using
an STM channel. 
You will have to think about lazyness, performance and space usage in
both cases, however.

Am Sonntag, den 17.01.2010, 20:48 +0100 schrieb Günther Schmidt:
 Hi,
 
 I know how to use Takusen with a *single* connection, but I cannot 
 figure out how to read from one database while inserting to another.
 
 
 Could someone please explain to me how I can do that?
 
 Günther
 
 
 ___
 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] parallel matrix multiply (dph, par/pseq)

2010-01-18 Thread Rafael Gustavo da Cunha Pereira Pinto
I never used DPH, but for Matrices, I always tend to use Array (Int,Int)
Double, as it accesses its elements in O(1). Arrays also can be unboxed
(UArray), which are much faster, or monadic and mutable (MArray), which are
more flexible.

I don't know if it is possible to use Arrays with DPH...




On Sun, Jan 17, 2010 at 21:35, Johannes Waldmann 
waldm...@imn.htwk-leipzig.de wrote:

 Hello.

 How can I multiply matrices (of Doubles)
 with dph (-0.4.0)?  (ghc-6.12.1)  -  I was trying

 type Vector = [:Double:]
 type Matrix = [:Vector:]

 times :: Matrix - Matrix - Matrix
 times a b =
  mapP
  ( \ row - mapP ( \ col - sumP ( zipWithP (*) row col  ) )
  ( transposeP b )
  ) a

 but there is no such thing as transposeP.

 When I try any kind of index manipulations,
 the compiler invariably tells me
 that it does not want to build  [: :] - lists of indices
 (e.g., there is no enumFromToP)
 (I guess because I'm using Data.Array.Parallel.Prelude.Double)

 Puzzled - J.W.


 PS: what's the recommended way to multiply matrices
 (better modelled as   Array (Int,Int) Double   or  [[Double]] ?)
 with the  par/pseq  approach (if this is recommended at all)?

 As I said earlier, I just want to have some nice and easy benchmarks
 for demonstration in a lecture (to be run on 2, 4, or 8 cores).
 Of course if they work, I'd use them in real life as well...




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




-- 
Rafael Gustavo da Cunha Pereira Pinto
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Visualizing function application

2010-01-18 Thread Gleb Alexeyev

Martijn van Steenbergen wrote:

Dear café,

I am deeply impressed with Vacuum[1][2], Ubigraph[3] and especially 
their combination[4]. I can trivially and beautifully visualize the ASTs 
that my parser produces. I can visualize zippers of the ASTs and confirm 
that sharing is optimal.


Ubigraph is also able to animate graph *mutations*, as shown by the 
various demos on Ubigraph's website. How cool would it be if we could 
tell vacuum-ubigraph: here, show this tree, and then show how the tree 
changes when we apply this function on it. We could see how [1,2,3] is 
transformed into a ring when cycle is applied on it, or we could see how 
a list is consumed node by node when a foldr is applied.


I have no idea how difficult this is or how to begin, so I thought I'd 
throw the idea out here. Perhaps it is appealing enough that someone 
picks it up and implements it. :-)


Martijn.


[1] http://hackage.haskell.org/package/vacuum
[2] http://www.youtube.com/watch?v=oujaqo9GAmA
[3] http://ubietylab.net/ubigraph/content/Demos/index.html
[4] http://hackage.haskell.org/package/vacuum-ubigraph


Hello, Martijn.

I'm glad you found vacuum-ubigraph useful.

I have to tell you that it was hacked in a hour or so based on the code 
from vacuum-cairo. I'm in no way an expert in GHC runtime internals.


The spec of application visualization as you propose it is unclear: in 
what sense the list [1,2,3] is transformed to a ring, given that only 
values 1,2,3 are shared, not cons-cells? Can this definition of 
transformation be extrapolated to a function like parseXml :: [Char] - 
XmlTree?


As to 'list consumed by foldr', things seem even more unclear. I'm under 
impression that Vacuum allows inspection of representation of static 
values, and here we need the history of evaluation, with information 
which nodes and when get collected as garbage. I doubt this is possible, 
but we'll have to wait until Matt Morrow or anyone else more 
knowledgeable than me comments.


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


Re: [Haskell-cafe] PROPOSAL: Web application interface

2010-01-18 Thread Michael Snoyman
Mark, thanks for the response, it's very well thought out. Let me state two
things first to explain some of my design decisions.

Firstly, I'm shooting for lowest-common-denominator here. Right now, I see
that as the intersection between the CGI backend and a standalone server
backend; I think anything contained in both of those will be contained in
all other backends. If anyone has a contrary example, I'd be happy to see
it.

Secondly, the WAI is *not* designed to be user friendly. It's designed to
be efficient and portable. People looking for a user-friendly way to write
applications should be using some kind of frontend, either a framework, or
something like hack-frontend-monadcgi.

That said, let's address your specific comments.


On Mon, Jan 18, 2010 at 8:54 AM, Mark Lentczner ma...@glyphic.com wrote:

 I like this project! Thanks for resurrecting it!

 Some thoughts:

 Methods in HTTP are extensible. The type RequestMethod should probably have
 a catchall constructor
| Method B.ByteString

 Seems logical to me.


 Other systems (the WAI proposal on the Wiki, Hack, etc...) have broken the
 path into two parts: scriptName and pathInfo. While I'm not particularly
 fond of those names, they do break the path into traversed and
 non-traversed portions of the URL. This is very useful for achieving
 location independence of one's code. While this API is trying to stay
 agnostic to the web framework, some degree of traversal is pretty universal,
 and I think it would benefit being in here.

 Going to the standalone vs CGI example: in a CGI script, scriptName is a
well defined variable. However, it has absolutely no meaning to a standalone
handler. I think we're just feeding rubbish into the system. I'm also not
certain how one could *use* scriptName in any meaningful manner, outside of
trying to reconstruct a URL (more on this topic below).


 The fields serverPort, serverName, and urlScheme are typically only used by
 an application to reconstruct URLs for inclusion in the response. This is
 a constant source of bugs in many web sites. It is also a problem in
 creating modular web frameworks, since the application can't be unaware of
 its context (unless the server interprets and re-writes HTML and other
 content on the fly - which isn't realistic.) Perhaps a better solution would
 be to pass a URL generating function in the Request and hide all this. Of
 course, web frameworks *could* use these data to dispatch on virtual host
 like configurations. Though, perhaps that is the provenance of the server
 side of the this API? I don't have a concrete proposal here, just a gut that
 the inclusion of these breaks some amount of encapsulation we'd like to
 achieve for the Applications.

 I think it's impossible to ever reconstruct a URL for a CGI application.
I've tried it; once you start dealing with mod_rewrite, anything could
happen. Given that I think we should encourage users to make pretty URLs via
mod_rewrite, I oppose inserting such a function. When I need this kind of
information (many of my web apps do), I've put it in a configuration file.

However, I don't think it's a good idea to hide information that is
universal to all webapps. urlScheme in particular seems very important to
me; for example, maybe when serving an app over HTTPS you want to use a
secure static-file server as well. Frankly, I don't have a use case for
serverName and serverPort that don't involve reconstructing URLs, but my gut
feeling is better to leave it in the protocol in case it does have a use
case.


 The HTTP version information seems to have been dropped from Request. Alas,
 this is often needed when deciding what response headers to generate. I'm in
 favor of a simple data type for this:
data HttpVersion = Http09 | Http10 | Http11

 I had not thought of that at all, and I like it. However, do we want to
hard-code in all possible HTTP versions? In theory, there could be more
standards in the future. Plus, isn't Google currently working on a more
efficient approach to HTTP that would affect this?


 Using ByteString for all the non-body values I find awkward. Take headers,
 for example. The header names are going to come from a list of about 50 well
 known ones. It seems a shame that applications will be littered with
 expressions like:

[(B.pack Content-Type, B.pack text/html;charset=UTF-8)]

 Seems to me that it would be highly beneficial to include a module, say
 Network.WAI.Header, that defined these things:

[(Hdr.contentType, Hdr.mimeTextHtmlUtf8)]

 This approach would make WAI much more top-heavy and prone to becoming
out-of-date. I don't oppose having this module in a separate package, but I
want to keep WAI itself as lite as possible.


 Further, since non-fixed headers will be built up out of many little String
 bits, I'd just as soon have the packing and unpacking be done by the server
 side of this API, and let the applications deal with Strings for these
 little snippets both in 

Re: [Haskell-cafe] Takusen - reading from one db inserting into another

2010-01-18 Thread Alistair Bayley
Hello Günther,

 I know how to use Takusen with a *single* connection, but I cannot figure
 out how to read from one database while inserting to another.

At present it's not possible. The lats time you asked about it, Oleg
and I tried a design where the DBM monad becomes a DBMT monad
transformer. This permits multiple connections, but the resulting
user-land code didn't work as well as I wanted. If you like I can try
to tidy it up and send you the darcs patch.

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


Re: [Haskell-cafe] Takusen - reading from one db inserting into another

2010-01-18 Thread Günther Schmidt

Hello Alistair,

sorry for asking twice, I had forgotten that.

I took some time to try to figure out how to do it and always concluded 
from my understanding of Takusen that it shouldn't be possible. At least 
it seems I got that right, which is good by itself :) .


Thank you for your troubles but do not worry about the patch, I have 
switched back to using HDBC meanwhile. HDBC-ODBC has a slight problem 
with Access, I couldn't insert Doubles, well I could but the decimal 
separator got swallowed, and I worked around it by using pr-efilled 
SQL-statement strings instead of bound/prepared ones.


Günther

Am 18.01.10 13:00, schrieb Alistair Bayley:

Hello Günther,

   

I know how to use Takusen with a *single* connection, but I cannot figure
out how to read from one database while inserting to another.
 

At present it's not possible. The lats time you asked about it, Oleg
and I tried a design where the DBM monad becomes a DBMT monad
transformer. This permits multiple connections, but the resulting
user-land code didn't work as well as I wanted. If you like I can try
to tidy it up and send you the darcs patch.

Alistair
   



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


Re: [Haskell-cafe] ANN: atom-0.1.3

2010-01-18 Thread miaubiz


Tom Hawkins-2 wrote:
 
 If you are using the latest version of Atom, asserts are checked
 between the execution of every rule.  The way you've coded it, it may
 appear as if the assertions are checked along with the associated
 rules, but this is not the case.  And not only are the assertions not
 checked with the rules, they don't follow the period or phase
 constraints either.  So what you have is essentially 2 assertions that
 are being checked at every time instance and between every atom state
 update.
 

how should I feed test data into my system?

I am having quite a bit of trouble with testing an atom with hysteresis
because I always end up having an assertion fire before and after my test
data is updated.

I have essentially the following code:

inputs = [1, 2, 3, 4, 5]
expected = [6, 7, 8, 9, 10]

output - word16' output
input - word16' input

input == inputs !. clock
doStuff
assert fiveIsAdded $ (value output) ==. (expected !. clock)

doStuff
  atom addFive $ period 1 $ do
output == (value input 5) + 5
...

the only way I am able to write assertions is to duplicate the logic of
hysteresis into the assertions, which is not a reasonable way to go for me.  


Tom Hawkins-2 wrote:
 
 because covered is the second word of the line from the log, the name of
 cover must be a single word. assertions and atoms can contain spaces as
 far
 as I can tell.
 
 No, they really shouldn't.  I've been meaning to add some checks to
 enforce some naming rules, but haven't gotten around to it.
 

good to know.  thanks for the heads up.

br, 
miau
-- 
View this message in context: 
http://old.nabble.com/ANN%3A-atom-0.1.3-tp26624813p27211086.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] parallel matrix multiply (dph, par/pseq)

2010-01-18 Thread Bertram Felgenhauer
Johannes Waldmann wrote:
 Hello.
 
 How can I multiply matrices (of Doubles)
 with dph (-0.4.0)?  (ghc-6.12.1)  -  I was trying
 
 type Vector = [:Double:]
 type Matrix = [:Vector:]
 
 times :: Matrix - Matrix - Matrix
 times a b =
   mapP
   ( \ row - mapP ( \ col - sumP ( zipWithP (*) row col  ) )
   ( transposeP b )
   ) a
 
 but there is no such thing as transposeP.

It's possible to implement transposeP as follows,

{-# LANGUAGE PArr #-}
...
import qualified Data.Array.Parallel.Prelude.Int as I

transposeP :: Matrix - Matrix
transposeP a = let
h = lengthP a
w = lengthP (a !: 0)
rh = I.enumFromToP 0 (h I.- 1) -- or [: 0 .. h I.- 1 :]
rw = I.enumFromToP 0 (w I.- 1) -- or [: 0 .. w I.- 1 :]
  in
if h == 0 then [: :]
  else mapP (\y - mapP (\x - a !: x !: y) rh) rw

Maybe there is a better way?

Bertram

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


[Haskell-cafe] A numpy equivalent for Haskell

2010-01-18 Thread yair...@gmail.com
Hi Cafe,

I've created a numpy equivalent for Haskell. (Numpy is a python
library for multi-dimensional arrays and operations on them)

Code at http://github.com/yairchu/numkell
(not yet on hackage because it needs better names)

A numkell array is a pair of a function from integer inputs and a
range for its inputs (size).
This allows for easy memoizing into in-memory arrays, and
additionally, numkell arrays also support useful operations like
numpy's newaxis and folding axes away.
As the Array name was already taken, numkell's array is currently
called Funk (name suggestions very appreciated).

An example:
Given an bunch of vectors as a 2d array, compute the distance between
each pair of vectors

{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving,
TypeOperators #-}

import Data.HList
import Data.NumKell
import Data.Typeable

newtype PersonIdx = PersonIdx Int
  deriving (Enum, Eq, Integral, Num, Ord, Real, Show, Typeable)

newtype FeatureIdx = FeatureIdx Int
  deriving (Enum, Eq, Integral, Num, Ord, Real, Show, Typeable)

let personProps = fFromList [[5,3,2],[4,8,1],[2,6,9],[5,3,0]] :: Funk
(HJust PersonIdx :*: HJust FeatureIdx :*: HNil) Double

 personProps
  FeatureIdx   0   1   2
PersonIdx  +   -   -   -
0  | 5.0 3.0 2.0
1  | 4.0 8.0 1.0
2  | 2.0 6.0 9.0
3  | 5.0 3.0 0.0

 sumAxes (fmap (** 2) (liftF2 (-) (personProps !/ (SNewAxis .*. HNil)) 
 (personProps !/ (SAll .*. SNewAxis .*. HNil (TFalse .*. TFalse .*. TTrue 
 .*. HNil)

  PersonIdx0123
PersonIdx +----
0 |  0.0 27.0 67.0  4.0
1 | 27.0  0.0 72.0 27.0
2 | 67.0 72.0  0.0 99.0
3 |  4.0 27.0 99.0  0.0

In Python the last line looks shorter:

 ((personProps[newaxis] - personProps[:,newAxis]) ** 2).sum(2)

Mostly due to Python's slicing syntax sugar.
Still, numkell has one large benefit over numpy (apart from being for
Haskell): With numpy this example creates a temporary 3d array in
memory. In numkell the array is not allocated in memory unless fMemo
is called.

If anyone has comments, suggestions, naming suggestions, complaints,
etc, I would very much like to hear.

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


Re: [Haskell-cafe] A numpy equivalent for Haskell

2010-01-18 Thread Ivan Lazar Miljenovic
Did you know about hmatrix (available on Hackage) before you wrote this?

yair...@gmail.com yair...@gmail.com writes:

 Hi Cafe,

 I've created a numpy equivalent for Haskell. (Numpy is a python
 library for multi-dimensional arrays and operations on them)

 Code at http://github.com/yairchu/numkell
 (not yet on hackage because it needs better names)

 A numkell array is a pair of a function from integer inputs and a
 range for its inputs (size).
 This allows for easy memoizing into in-memory arrays, and
 additionally, numkell arrays also support useful operations like
 numpy's newaxis and folding axes away.
 As the Array name was already taken, numkell's array is currently
 called Funk (name suggestions very appreciated).

 An example:
 Given an bunch of vectors as a 2d array, compute the distance between
 each pair of vectors

 {-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving,
 TypeOperators #-}

 import Data.HList
 import Data.NumKell
 import Data.Typeable

 newtype PersonIdx = PersonIdx Int
   deriving (Enum, Eq, Integral, Num, Ord, Real, Show, Typeable)

 newtype FeatureIdx = FeatureIdx Int
   deriving (Enum, Eq, Integral, Num, Ord, Real, Show, Typeable)

 let personProps = fFromList [[5,3,2],[4,8,1],[2,6,9],[5,3,0]] :: Funk
 (HJust PersonIdx :*: HJust FeatureIdx :*: HNil) Double

 personProps
   FeatureIdx   0   1   2
 PersonIdx  +   -   -   -
 0  | 5.0 3.0 2.0
 1  | 4.0 8.0 1.0
 2  | 2.0 6.0 9.0
 3  | 5.0 3.0 0.0

 sumAxes (fmap (** 2) (liftF2 (-) (personProps !/ (SNewAxis .*. HNil)) 
 (personProps !/ (SAll .*. SNewAxis .*. HNil (TFalse .*. TFalse .*. TTrue 
 .*. HNil)

   PersonIdx0123
 PersonIdx +----
 0 |  0.0 27.0 67.0  4.0
 1 | 27.0  0.0 72.0 27.0
 2 | 67.0 72.0  0.0 99.0
 3 |  4.0 27.0 99.0  0.0

 In Python the last line looks shorter:

 ((personProps[newaxis] - personProps[:,newAxis]) ** 2).sum(2)

 Mostly due to Python's slicing syntax sugar.
 Still, numkell has one large benefit over numpy (apart from being for
 Haskell): With numpy this example creates a temporary 3d array in
 memory. In numkell the array is not allocated in memory unless fMemo
 is called.

 If anyone has comments, suggestions, naming suggestions, complaints,
 etc, I would very much like to hear.

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

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A numpy equivalent for Haskell

2010-01-18 Thread Yair Chuchem
On Mon, Jan 18, 2010 at 4:56 PM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 Did you know about hmatrix (available on Hackage) before you wrote this?

yes.
hmatrix is equivalent to other parts of numpy.
iirc hmatrix is a wrapper for algorithms from GSL+BLAS+LAPACK.
numkell is only equivalent to numpy's core array type  functionality,
without numpy's included linalg algorithms (which in Python are
especially needed since coding them in Python will result in very slow
code)

hTensor seems to be more similar to numkell, as it also provides a
multi-dimensional array type.
however, if I understand correctly, hTensor is quite different.
* numkell array's axes are part of their types. in hTensor those are
only known in run-time. so numkell is more type-safe imho.
* numkell's array zips are lazy/not-memoized by default. I may be
wrong on this, but it seems that hTensor always creates in-memory
arrays.

 yair...@gmail.com yair...@gmail.com writes:

 Hi Cafe,

 I've created a numpy equivalent for Haskell. (Numpy is a python
 library for multi-dimensional arrays and operations on them)

 Code at http://github.com/yairchu/numkell
 (not yet on hackage because it needs better names)

 A numkell array is a pair of a function from integer inputs and a
 range for its inputs (size).
 This allows for easy memoizing into in-memory arrays, and
 additionally, numkell arrays also support useful operations like
 numpy's newaxis and folding axes away.
 As the Array name was already taken, numkell's array is currently
 called Funk (name suggestions very appreciated).

 An example:
 Given an bunch of vectors as a 2d array, compute the distance between
 each pair of vectors

 {-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving,
 TypeOperators #-}

 import Data.HList
 import Data.NumKell
 import Data.Typeable

 newtype PersonIdx = PersonIdx Int
   deriving (Enum, Eq, Integral, Num, Ord, Real, Show, Typeable)

 newtype FeatureIdx = FeatureIdx Int
   deriving (Enum, Eq, Integral, Num, Ord, Real, Show, Typeable)

 let personProps = fFromList [[5,3,2],[4,8,1],[2,6,9],[5,3,0]] :: Funk
 (HJust PersonIdx :*: HJust FeatureIdx :*: HNil) Double

 personProps
           FeatureIdx   0   1   2
 PersonIdx          +   -   -   -
         0          | 5.0 3.0 2.0
         1          | 4.0 8.0 1.0
         2          | 2.0 6.0 9.0
         3          | 5.0 3.0 0.0

 sumAxes (fmap (** 2) (liftF2 (-) (personProps !/ (SNewAxis .*. HNil)) 
 (personProps !/ (SAll .*. SNewAxis .*. HNil (TFalse .*. TFalse .*. 
 TTrue .*. HNil)

           PersonIdx    0    1    2    3
 PersonIdx         +    -    -    -    -
         0         |  0.0 27.0 67.0  4.0
         1         | 27.0  0.0 72.0 27.0
         2         | 67.0 72.0  0.0 99.0
         3         |  4.0 27.0 99.0  0.0

 In Python the last line looks shorter:

 ((personProps[newaxis] - personProps[:,newAxis]) ** 2).sum(2)

 Mostly due to Python's slicing syntax sugar.
 Still, numkell has one large benefit over numpy (apart from being for
 Haskell): With numpy this example creates a temporary 3d array in
 memory. In numkell the array is not allocated in memory unless fMemo
 is called.

 If anyone has comments, suggestions, naming suggestions, complaints,
 etc, I would very much like to hear.

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

 --
 Ivan Lazar Miljenovic
 ivan.miljeno...@gmail.com
 IvanMiljenovic.wordpress.com

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


Re: [Haskell-cafe] ANN: atom-0.1.3

2010-01-18 Thread miaubiz


Tom Hawkins-2 wrote:
 
 Would you explain what you are trying to do a bet more clearly?
 

Certainly.  I am writing an autonomous rover.  To choose the direction to
drive towards, the car compares the direction it wants to go with the
direction it is actually facing.  To avoid continuously zigzagging I have
hysteresis set around the target direction.

1. I have a set of test inputs
2. I want to run my atoms
3. I want to verify that the state of my atom matches a specific state after
each iteration

t2 = defaultTest {
  testbench = steeringVsBearing
 ,declCode = header fakeHeaders
 ,cycles = (length testData)
}

steeringVsBearing :: Atom () -- this is only a test
steeringVsBearing = do
  steering - word8' steering
  targetHeadings - array targetHeadings  ([target | (target, _, _) -
testData])
  actualHeadings - array actualHeadings  ([actual | (_, actual, _) -
testData])
  expectedSteerings - array expectedSteerings ([steerings |(_, _,
steerings) - testData]) 
  targetHeading == targets !. clock
  compass == actuals !. clock

  navigate --this is my production atom
  assert steeringWorks $ (value steering) ==. (expectedSteerings !. clock)

navigate = do
  steering - word8' steering
  
  period 1 $ atom figureOutWhichWayToGo $ do
 --calculate steering based on target heading and actual heading
 --blah blah
steering' - do return $ mux l1 (mux r1 75 90) 105
steering == steering'


Tom Hawkins-2 wrote:
 
 output - word16' output
 input - word16' input

 input == inputs !. clock
 
 There are a few potential problems with this statement.  First,
 'input' in an external variable -- which is fine, just be sure nothing
 is being assigned to it in the external c code.  Note, if 'input' is
 not referenced by external code, then 'word16 input 0' would be a
 better variable declaration.
 

I used an external variable because I wanted to reference it both in
steeringVsBearing which is a test function, and the actual function
navigate.  


Tom Hawkins-2 wrote:
 
 The second problem is a bit more serious.  By using the 'clock' as an
 array index, it will eventually go outside the bounds of the array.
 Beware: Atom provides no array checks, such as index-out-of-bounds, or
 assigning the same array location multiple times within the same
 atomic action.
 

ok.  I am using clock as an index in the test function only. 


Tom Hawkins-2 wrote:
 
 doStuff
 assert fiveIsAdded $ (value output) ==. (expected !. clock)
 
 Keep in mind than multiple rules will fire in one 'clock' cycle, and
 assertions are checked between the execution of each rule.  In this
 case, the assertion will be checked before the top level rule that
 contains the assignment 'input == inputs !. clock', and before the
 addFive rule.  In both cases 'clock' will have the same value, which
 will probably lead to an assertion violation.
 

I am unable to come up with any assertions that would be valid all the time,
which would allow me to feed test data into my atoms and then verifying them
against some known inputs.

I have some other asserts that I find helpful, such as (minus the spaces):

  assert target is closer than 1800 to actual (target' - actual' =. 1800)
  assert target is closer than 1800 to actual' (actual' - target' =.
1800)

but checking that the steering is valid is more difficult because it depends
on the previous state of steering due to hysteresis.

I don't want to replicate the logic of hysteresis in the assertion:

assert steeringWorks $ mux (previousSteering `lt_` 90) mux
(currentSteering `gt_` 90) etc etc etc.


Tom Hawkins-2 wrote:
 

 doStuff
  atom addFive $ period 1 $ do
    output == (value input 5) + 5
 
 This last statement should yield a type violation.  (value input 5).
 

that was a typo on my part. 

I assume I am totally off on my testing attempt, and if you could point me
in the right direction I would greatly appreciate it.

Br, 
Miau

-- 
View this message in context: 
http://old.nabble.com/ANN%3A-atom-0.1.3-tp26624813p27212766.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


[Haskell-cafe] ghc make install question

2010-01-18 Thread Johannes Waldmann
Hi.

How can I get make install from a ghc (snapshot) source dir
to install binaries $prefix/bin/ghc{,i,-pkg}-$version
but *not* overwrite the un-versioned symlinks?

Thanks - J.W.



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


[Haskell-cafe] Newbie question about Parsec

2010-01-18 Thread david fries
Hey everybody

I've been playing around with Parsec a little bit lately. I like it a
lot, but now I've hit a bit of a challenge. Suppose I have to parse a
variable length string representing a time interval. Depending on how
many fields there are, the time is either interpreted as seconds,
minutes and seconds or hours, minutes and seconds. 

For example:

... 31 ... would be parsed as 31 seconds.
... 05:31 ... would be parsed as 5 minutes and 31 seconds.
... 01:05:31 ... would be parsed as 1 hour, 5 minutes and 31 seconds. 

I've come up with the following solution using optionMaybe to deal with
the problem:

data ElapsedTime = ElapsedTime {
 hours :: Int,
 minutes :: Int,
 seconds :: Int
} deriving (Show, Eq, Ord)

p_elapsed_time :: CharParser () ElapsedTime
p_elapsed_time = toElapsedTime $ (optionMaybe p_Int) 
   * (optionMaybe (char ':' * p_Int))
   * (optionMaybe (char ':' * p_Int *
skipSpaces))
where toElapsedTime Nothing Nothing Nothing = ElapsedTime 0 0 0
  toElapsedTime (Just s) Nothing Nothing = ElapsedTime 0 0 s
  toElapsedTime (Just m) (Just s) Nothing = ElapsedTime 0 m s
  toElapsedTime (Just h) (Just m) (Just s) = ElapsedTime h m s


Where p_Int simply parses a sequence of digits as an Int and skipSpaces
does just that.

This works correctly, but it also feels kinda clumsy. For one the
compiler rightly complains about non-exhaustive pattern matches in the
definition of the toElapsedTime function, although I believe that's
negligible in that particular case. 
Is there a better i.e. more elegant way to tackle such a problem? 

regards,
david 

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


Re: [Haskell-cafe] Newbie question about Parsec

2010-01-18 Thread Daniel Fischer
Am Montag 18 Januar 2010 19:09:23 schrieb david fries:
 Hey everybody

 I've been playing around with Parsec a little bit lately. I like it a
 lot, but now I've hit a bit of a challenge. Suppose I have to parse a
 variable length string representing a time interval. Depending on how
 many fields there are, the time is either interpreted as seconds,
 minutes and seconds or hours, minutes and seconds.

 For example:

 ... 31 ... would be parsed as 31 seconds.
 ... 05:31 ... would be parsed as 5 minutes and 31 seconds.
 ... 01:05:31 ... would be parsed as 1 hour, 5 minutes and 31 seconds.

 I've come up with the following solution using optionMaybe to deal with
 the problem:

 data ElapsedTime = ElapsedTime {
  hours :: Int,
  minutes :: Int,
  seconds :: Int
 } deriving (Show, Eq, Ord)

 p_elapsed_time :: CharParser () ElapsedTime
 p_elapsed_time = toElapsedTime $ (optionMaybe p_Int)
* (optionMaybe (char ':' * p_Int))
* (optionMaybe (char ':' * p_Int *
 skipSpaces))
 where toElapsedTime Nothing Nothing Nothing = ElapsedTime 0 0 0
   toElapsedTime (Just s) Nothing Nothing = ElapsedTime 0 0 s
   toElapsedTime (Just m) (Just s) Nothing = ElapsedTime 0 m s
   toElapsedTime (Just h) (Just m) (Just s) = ElapsedTime h m s


p_elapsed_time = toElapsedTime $ sepBy p_int (char ':')
   where
  toElapsedTime (h:m:s:_) = ElapsedTime h m s
  toElapsedTime [m,s] = ElapsedTime 0 m s
  toElapsedTime [s]   = ElapsedTime 0 0 s
  toElapsedTime []= ElapsedTime 0 0 0

You can replace the first pattern for toElapsedTime with [h,m,s] and add a 
failure case if sepBy p_int (char ':') parses more than three ints (or 
write a combinator that parses up to n results of p separated by sep).

Or

p_elapsed_time = do
s - p_int
et - cont_elapsed_time (ElapsedTime 0 0 s)

cont_elapsed_time et@(ElapsedTime h m s) = do
char ':'
n - p_int
cont_elapsed_time (ElapsedTime m s n)
   | return et


 Where p_Int simply parses a sequence of digits as an Int and skipSpaces
 does just that.

 This works correctly, but it also feels kinda clumsy. For one the
 compiler rightly complains about non-exhaustive pattern matches in the
 definition of the toElapsedTime function, although I believe that's
 negligible in that particular case.
 Is there a better i.e. more elegant way to tackle such a problem?

 regards,
 david


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


[Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread michael rice
I downloaded XMonad from the Fedora 12 repository and would like to see it in 
action.

What must I do to get it working from the Gnome desktop environment?

Michael



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


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread Ivan Lazar Miljenovic
michael rice nowg...@yahoo.com writes:

 I downloaded XMonad from the Fedora 12 repository and would like to see it in 
 action.

 What must I do to get it working from the Gnome desktop environment?

See the associated documentation at http://www.haskell.org/haskellwiki/Xmonad

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Broken registration link on hackage trac

2010-01-18 Thread Andy Gimblett

Hi all,

I want to register an account on hackage's trac instance, but the  
register an account link on the start page:


http://hackage.haskell.org/trac/hackage/wiki/WikiStart

is broken.

I'm guessing someone here knows what it should be and has registered  
already and thus can fix it.  :-)


Cheers,

-Andy

--
Andy Gimblett
http://gimbo.org.uk/

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


Re: [Haskell-cafe] Poor man's generic programming

2010-01-18 Thread Neil Mitchell
Hi Henning,

Uniplate might be the answer you are looking for -
http://community.haskell.org/~ndm/uniplate

Uniplate is simple (only multi parameter type classes, and even then
only in a very simple usage), fast (one of the fastest generics
libraries) and concise (probably the most concise generics library).
It's also not as powerful as most of the other generics libraries, but
I find it does about 98% of the generics tasks I need. Uniplate is
used extensively in virtually all my tools, for example HLint.

As an example, I guess your function returns all the Int's embedded
within a data type, at any level? If so, uniplate already has the
universeBi method which does that for you, and doesn't require you to
do anything.

Thanks, Neil

2010/1/16 Henning Thielemann schlepp...@henning-thielemann.de:
 Is any of the existing Generics packages able to work without compiler 
 extensions, that is Haskell 98?
 I mean, it is ok if the developer of the generic parts of a library needs 
 compiler extensions or extra tools, but the user who calls 'cabal install' 
 shall not need them and the developer, who does not touch generic 
 definitions, should not need them as well.

 I think this could be done with pragmas in the following way:

 class C a where
  f :: a - [Int]
  {-# GENERICDEFAULT
  f {| Unit |} Unit = []
  #-}

 {-# GENERATEDINSTANCEBEGIN Automatically generated - Do not edit! #-}
 instance C () where
  f () = []
 {-# GENERATEDINSTANCEEND Automatically generated - Do not edit! #-}

 Now, by running a tool, the part between the GENERATEDINSTANCE pragmas can 
 generated or updated.
 Everything outside the pragmas can be Haskell 98.

 It does not only avoid extensions of the building compiler, but also 
 extensions of a programmer's brain. Because for programmers it is often 
 easier to understand a set of instances and see the common patterns, than to 
 understand generic code that builds the instances.

 ___
 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


[Haskell-cafe] Windows emulator for testing purposes

2010-01-18 Thread Gregory Crosswhite
Hey everyone!

I have a Linux machine and a OSX machine, and I am developing packages that I 
would like to upload to Hackage one day.  Do you have any recommendations for a 
free/open source solution that would let me emulate a Windows environment for 
testing purposes?

Cheers,
Greg

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


Re: [Haskell-cafe] Windows emulator for testing purposes

2010-01-18 Thread Rahul Kapoor
 Do you have any recommendations for a free/open source solution that would 
let me emulate a Windows
environment for testing purposes?

Sun's Virtual Box? - http://www.virtualbox.org/

You would still need a Windows license though.

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


Re: [Haskell-cafe] Windows emulator for testing purposes

2010-01-18 Thread Brandon S. Allbery KF8NH

On Jan 18, 2010, at 15:12 , Rahul Kapoor wrote:
 Do you have any recommendations for a free/open source solution  
that would let me emulate a Windows

environment for testing purposes?


Sun's Virtual Box? - http://www.virtualbox.org/
You would still need a Windows license though.



I wonder if Wine would be good enough for testing.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
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] Windows emulator for testing purposes

2010-01-18 Thread Gregory Crosswhite
Does anyone have experience with ReactOS?

Cheers,
Greg


On Jan 18, 2010, at 12:12 PM, Rahul Kapoor wrote:

  Do you have any recommendations for a free/open source solution that would 
 let me emulate a Windows
 environment for testing purposes?
 
 Sun's Virtual Box? - http://www.virtualbox.org/
 
 You would still need a Windows license though.
 
 Cheers,
 Rahul

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


Re: [Haskell-cafe] Windows emulator for testing purposes

2010-01-18 Thread Ivan Lazar Miljenovic
Brandon S. Allbery KF8NH allb...@ece.cmu.edu writes:
 I wonder if Wine would be good enough for testing.

If memory serves me correctly, I have heard about people installing the
Windows version of GHC and using it under Wine for testing purposes...

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread michael rice
I'd already found a lot of these links and tried some of their suggestions, 
without any success. Does anyone who posts here actually use it (what platform)?

Michael

--- On Mon, 1/18/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote:

From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com
Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Monday, January 18, 2010, 1:57 PM

michael rice nowg...@yahoo.com writes:

 I downloaded XMonad from the Fedora 12 repository and would like to see it in 
 action.

 What must I do to get it working from the Gnome desktop environment?

See the associated documentation at http://www.haskell.org/haskellwiki/Xmonad

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com



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


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread Don Stewart
nowgate:
 I'd already found a lot of these links and tried some of their suggestions,
 without any success. Does anyone who posts here actually use it (what
 platform)?

What's the problem exactly?

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


[Haskell-cafe] Please help me debug my arrow

2010-01-18 Thread Paul Johnson

Hi,

I'm trying to write an arrow for a real-time stream processor.  I'm 
basing it on the SP type in Hughes paper on Generalising Monads to 
Arrows (http://www.cs.chalmers.se/~rjmh/Papers/arrows.pdf) section 6.  
I've extended this with a notion of time by making each step a function 
of time.  But I can't get the compose operator to work.


The arrow itself is defined in http://haskell.pastebin.com/m49944f64 
with the (.) function highlighted.  Some simple tests are in 
http://haskell.pastebin.com/m6d90f27 with the problematic call highlighted.


When run it produces an infinite list of puts, which causes the 
SimulateRTSP interpreter function to diverge.  But I've run the 
expansions by hand, and they seem to work (see the test case file at the 
bottom).


I'm going nuts looking at this.  Can anyone see what I'm doing wrong?

Thanks,

Paul.


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


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread Ivan Lazar Miljenovic
michael rice nowg...@yahoo.com writes:

 I'd already found a lot of these links and tried some of their
 suggestions, without any success. Does anyone who posts here actually
 use it (what platform)?

Note that XMonad has its own dedicated mailing list as well...


 Michael

 --- On Mon, 1/18/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote:

 From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com
 Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
 To: michael rice nowg...@yahoo.com
 Cc: haskell-cafe@haskell.org
 Date: Monday, January 18, 2010, 1:57 PM

 michael rice nowg...@yahoo.com writes:

 I downloaded XMonad from the Fedora 12 repository and would like to see it 
 in action.

 What must I do to get it working from the Gnome desktop environment?

 See the associated documentation at http://www.haskell.org/haskellwiki/Xmonad

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread michael rice
Well, for starters the Fedora entry for installing XMonad is blank/empty:
http://www.haskell.org/haskellwiki/Xmonad/Installing_xmonad#Fedora

Some things I've done:

I set up a .xmonad directory in my home directory with this xmonad.hs

[mich...@localhost ~]$ cat ~/.xmonad/xmonad.hs
    --
    -- An example, simple ~/.xmonad/xmonad.hs file.
    -- It overrides a few basic settings, reusing all the other defaults.
    --

    import XMonad

    main = xmonad $ defaultConfig
    { borderWidth    = 2
    , terminal   = urxvt
    , normalBorderColor  = #cc
    , focusedBorderColor = #cd8b00 }

[mich...@localhost ~]$ 

I set up a .xsession directory in my home directory with this in it

[mich...@localhost ~]$ cat .xsession
export WINDOW_MANAGER=/usr/bin/xmonad
exec gnome-session 

[mich...@localhost ~]$ 

Because supposedly X doesn't even check .xsession file without having 
xorg-x11-xinit-session installed, I also downloaded that.

I set up a XMonad.desktop file in /usr/share/applications directory

[mich...@localhost ~]$ cat /usr/share/applications/Xmonad.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Xmonad
# change this path according to your xmonad binary
Exec=/usr/bin/xmonad
NoDisplay=true
X-GNOME-WMName=Xmonad
X-GNOME-Bugzilla-Bugzilla=XMonad
X-GNOME-Bugzilla-Product=xmonad
X-GNOME-Bugzilla-Component=general
X-GNOME-Autostart-Phase=WindowManager
X-GNOME-Provides=windowmanager
X-GNOME-Autostart-Notify=true
[mich...@localhost ~]$ 

I added /usr/bin/xmonad to startup applications.

All these things were suggested.

Michael

--- On Mon, 1/18/10, Don Stewart d...@galois.com wrote:

From: Don Stewart d...@galois.com
Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
To: michael rice nowg...@yahoo.com
Cc: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com, 
haskell-cafe@haskell.org
Date: Monday, January 18, 2010, 3:30 PM

nowgate:
 I'd already found a lot of these links and tried some of their suggestions,
 without any success. Does anyone who posts here actually use it (what
 platform)?

What's the problem exactly?

-- Don



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


Re[2]: [Haskell-cafe] Poor man's generic programming

2010-01-18 Thread Bulat Ziganshin
Hello Neil,

Monday, January 18, 2010, 10:56:00 PM, you wrote:

 Uniplate might be the answer you are looking for -
 http://community.haskell.org/~ndm/uniplate

it's brilliant! some people has the talent to discover complex things
and you have the talent to make complex things simple. it's first and only
generics library that i can easily learn and remember

can you give a permission to translate 
http://community.haskell.org/~ndm/darcs/uniplate/uniplate.htm
to Russian for http://fprog.ru/ online functional programming journal?


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


[Haskell-cafe] Mini-announce: A few package updates

2010-01-18 Thread Andrew Coppin
In case somebody else on this planet besides me is using these... I've 
just updated my handful of packages on Hackage so they should now build 
with GHC 6.12.1. (In most cases, just tweaks to the package 
dependancies.) I have also changed the documentation for 
AC-EasyRaster-GTK, to hopefully make it clearer that all the 
event-related stuff is ONLY necessary if you want to display your images 
in a GTK window. Oh, and I discovered that I fail basic linear algebra; 
the AC-Vector package had a bug in vcross, which is fixed in 1.2.2 (but 
exists in all prior versions). AC-Vector gets a minor version bump 
because I renamed some stuff; nothing really exciting is different.


PS. Apparently AC-VanillaArray causes GHC 6.12.1 to panic during 
compilation... I'll have to investigate that. Still, it does play with 
GHC.Prim, so that's probably got something to do with it.


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


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread Ivan Lazar Miljenovic
Oh, is Fedora still using a version of GDM that doesn't let you use a
custom .Xsession (or even remember that you want to use something that
isn't called Gnome)?

michael rice nowg...@yahoo.com writes:

 Well, for starters the Fedora entry for installing XMonad is blank/empty:
 http://www.haskell.org/haskellwiki/Xmonad/Installing_xmonad#Fedora

 Some things I've done:

 I set up a .xmonad directory in my home directory with this xmonad.hs

 [mich...@localhost ~]$ cat ~/.xmonad/xmonad.hs
     --
     -- An example, simple ~/.xmonad/xmonad.hs file.
     -- It overrides a few basic settings, reusing all the other defaults.
     --

     import XMonad

     main = xmonad $ defaultConfig
     { borderWidth    = 2
     , terminal   = urxvt
     , normalBorderColor  = #cc
     , focusedBorderColor = #cd8b00 }

 [mich...@localhost ~]$ 

 I set up a .xsession directory in my home directory with this in it

 [mich...@localhost ~]$ cat .xsession
 export WINDOW_MANAGER=/usr/bin/xmonad
 exec gnome-session 

 [mich...@localhost ~]$ 

 Because supposedly X doesn't even check .xsession file without having 
 xorg-x11-xinit-session installed, I also downloaded that.

 I set up a XMonad.desktop file in /usr/share/applications directory

 [mich...@localhost ~]$ cat /usr/share/applications/Xmonad.desktop
 [Desktop Entry]
 Type=Application
 Encoding=UTF-8
 Name=Xmonad
 # change this path according to your xmonad binary
 Exec=/usr/bin/xmonad
 NoDisplay=true
 X-GNOME-WMName=Xmonad
 X-GNOME-Bugzilla-Bugzilla=XMonad
 X-GNOME-Bugzilla-Product=xmonad
 X-GNOME-Bugzilla-Component=general
 X-GNOME-Autostart-Phase=WindowManager
 X-GNOME-Provides=windowmanager
 X-GNOME-Autostart-Notify=true
 [mich...@localhost ~]$ 

 I added /usr/bin/xmonad to startup applications.

 All these things were suggested.

 Michael

 --- On Mon, 1/18/10, Don Stewart d...@galois.com wrote:

 From: Don Stewart d...@galois.com
 Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
 To: michael rice nowg...@yahoo.com
 Cc: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com, 
 haskell-cafe@haskell.org
 Date: Monday, January 18, 2010, 3:30 PM

 nowgate:
 I'd already found a lot of these links and tried some of their suggestions,
 without any success. Does anyone who posts here actually use it (what
 platform)?

 What's the problem exactly?

 -- Don



   

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread michael rice
Perhaps. Is there a Linux distro that's more XMonad friendly?

Michael

--- On Mon, 1/18/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote:

From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com
Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
To: michael rice nowg...@yahoo.com
Cc: Don Stewart d...@galois.com, haskell-cafe@haskell.org
Date: Monday, January 18, 2010, 4:26 PM

Oh, is Fedora still using a version of GDM that doesn't let you use a
custom .Xsession (or even remember that you want to use something that
isn't called Gnome)?

michael rice nowg...@yahoo.com writes:

 Well, for starters the Fedora entry for installing XMonad is blank/empty:
 http://www.haskell.org/haskellwiki/Xmonad/Installing_xmonad#Fedora

 Some things I've done:

 I set up a .xmonad directory in my home directory with this xmonad.hs

 [mich...@localhost ~]$ cat ~/.xmonad/xmonad.hs
     --
     -- An example, simple ~/.xmonad/xmonad.hs file.
     -- It overrides a few basic settings, reusing all the other defaults.
     --

     import XMonad

     main = xmonad $ defaultConfig
     { borderWidth    = 2
     , terminal   = urxvt
     , normalBorderColor  = #cc
     , focusedBorderColor = #cd8b00 }

 [mich...@localhost ~]$ 

 I set up a .xsession directory in my home directory with this in it

 [mich...@localhost ~]$ cat .xsession
 export WINDOW_MANAGER=/usr/bin/xmonad
 exec gnome-session 

 [mich...@localhost ~]$ 

 Because supposedly X doesn't even check .xsession file without having 
 xorg-x11-xinit-session installed, I also downloaded that.

 I set up a XMonad.desktop file in /usr/share/applications directory

 [mich...@localhost ~]$ cat /usr/share/applications/Xmonad.desktop
 [Desktop Entry]
 Type=Application
 Encoding=UTF-8
 Name=Xmonad
 # change this path according to your xmonad binary
 Exec=/usr/bin/xmonad
 NoDisplay=true
 X-GNOME-WMName=Xmonad
 X-GNOME-Bugzilla-Bugzilla=XMonad
 X-GNOME-Bugzilla-Product=xmonad
 X-GNOME-Bugzilla-Component=general
 X-GNOME-Autostart-Phase=WindowManager
 X-GNOME-Provides=windowmanager
 X-GNOME-Autostart-Notify=true
 [mich...@localhost ~]$ 

 I added /usr/bin/xmonad to startup applications.

 All these things were suggested.

 Michael

 --- On Mon, 1/18/10, Don Stewart d...@galois.com wrote:

 From: Don Stewart d...@galois.com
 Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
 To: michael rice nowg...@yahoo.com
 Cc: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com, 
 haskell-cafe@haskell.org
 Date: Monday, January 18, 2010, 3:30 PM

 nowgate:
 I'd already found a lot of these links and tried some of their suggestions,
 without any success. Does anyone who posts here actually use it (what
 platform)?

 What's the problem exactly?

 -- Don



       

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com



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


Re: [Haskell-cafe] Windows emulator for testing purposes

2010-01-18 Thread Jeff Zaroyko
On Tue, Jan 19, 2010 at 7:27 AM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 Brandon S. Allbery KF8NH allb...@ece.cmu.edu writes:
 I wonder if Wine would be good enough for testing.

 If memory serves me correctly, I have heard about people installing the
 Windows version of GHC and using it under Wine for testing purposes...

 --
 Ivan Lazar Miljenovic
 ivan.miljeno...@gmail.com
 IvanMiljenovic.wordpress.com

It does work, just make sure you're using a sufficiently new version
of Wine, git or a development version from http://winehq.org/download

Older versions had a bug which broke cabal install, but I submitted a
patch for that.  What doesn't work is the installer for cygwin if you
require that, otherwise msys-git works fine for providing a bash to
run configure scripts, so long as you install mingw and update your
path, things will work pretty much the same as Windows.

http://www.haskell.org/haskellwiki/GHC_under_WINE

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


Re: [Haskell-cafe] Windows emulator for testing purposes

2010-01-18 Thread Stephen Tetley
Hello Gregory

If the packages are FFI-free they should just work (ahem, perhaps
with some caveats about e.g. file paths - if they have data files
included).

If they have FFI dependencies then a Windows emulator is going to have
to emulate Unix in turn (either via MinGW or Cygwin). It might be more
productive to simply label them as Untested under Windows and make a
reference to the FFI dependencies.

Best wishes

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


[Haskell-cafe] Re: Windows emulator for testing purposes

2010-01-18 Thread Maciej Piechotka
On Mon, 2010-01-18 at 12:04 -0800, Gregory Crosswhite wrote:
 Hey everyone!
 
 I have a Linux machine and a OSX machine, and I am developing packages that I 
 would like to upload to Hackage one day.  Do you have any recommendations for 
 a free/open source solution that would let me emulate a Windows environment 
 for testing purposes?
 
 Cheers,
 Greg

Wine is not emulator - but depending on the task it may suit you. You
can even just link against winelib.

If you have a license (IANAL but AFAIR is counting as separate copy.
Judging by your email you are in some educational institution - check if
you have access to MSDNAA [and license allows you to use it]) you can
set up any x86 emulator or have dual boot.

Regards


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


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread John Millikin
I've been quite happy with Ubuntu's xmonad package, though I run it
within a GNOME session.

Have you tried the instructions on the XMonad wiki for inter-operating
with GNOME? http://www.haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Gnome

On Mon, Jan 18, 2010 at 13:40, michael rice nowg...@yahoo.com wrote:

 Perhaps. Is there a Linux distro that's more XMonad friendly?

 Michael

 --- On Mon, 1/18/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote:

 From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com
 Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
 To: michael rice nowg...@yahoo.com
 Cc: Don Stewart d...@galois.com, haskell-cafe@haskell.org
 Date: Monday, January 18, 2010, 4:26 PM

 Oh, is Fedora still using a version of GDM that doesn't let you use a
 custom .Xsession (or even remember that you want to use something that
 isn't called Gnome)?

 michael rice nowg...@yahoo.com writes:

  Well, for starters the Fedora entry for installing XMonad is blank/empty:
  http://www.haskell.org/haskellwiki/Xmonad/Installing_xmonad#Fedora
 
  Some things I've done:
 
  I set up a .xmonad directory in my home directory with this xmonad.hs
 
  [mich...@localhost ~]$ cat ~/.xmonad/xmonad.hs
      --
      -- An example, simple ~/.xmonad/xmonad.hs file.
      -- It overrides a few basic settings, reusing all the other defaults.
      --
 
      import XMonad
 
      main = xmonad $ defaultConfig
      { borderWidth    = 2
      , terminal   = urxvt
      , normalBorderColor  = #cc
      , focusedBorderColor = #cd8b00 }
 
  [mich...@localhost ~]$
 
  I set up a .xsession directory in my home directory with this in it
 
  [mich...@localhost ~]$ cat .xsession
  export WINDOW_MANAGER=/usr/bin/xmonad
  exec gnome-session
 
  [mich...@localhost ~]$
 
  Because supposedly X doesn't even check .xsession file without having 
  xorg-x11-xinit-session installed, I also downloaded that.
 
  I set up a XMonad.desktop file in /usr/share/applications directory
 
  [mich...@localhost ~]$ cat /usr/share/applications/Xmonad.desktop
  [Desktop Entry]
  Type=Application
  Encoding=UTF-8
  Name=Xmonad
  # change this path according to your xmonad binary
  Exec=/usr/bin/xmonad
  NoDisplay=true
  X-GNOME-WMName=Xmonad
  X-GNOME-Bugzilla-Bugzilla=XMonad
  X-GNOME-Bugzilla-Product=xmonad
  X-GNOME-Bugzilla-Component=general
  X-GNOME-Autostart-Phase=WindowManager
  X-GNOME-Provides=windowmanager
  X-GNOME-Autostart-Notify=true
  [mich...@localhost ~]$
 
  I added /usr/bin/xmonad to startup applications.
 
  All these things were suggested.
 
  Michael
 
  --- On Mon, 1/18/10, Don Stewart d...@galois.com wrote:
 
  From: Don Stewart d...@galois.com
  Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
  To: michael rice nowg...@yahoo.com
  Cc: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com, 
  haskell-cafe@haskell.org
  Date: Monday, January 18, 2010, 3:30 PM
 
  nowgate:
  I'd already found a lot of these links and tried some of their suggestions,
  without any success. Does anyone who posts here actually use it (what
  platform)?
 
  What's the problem exactly?
 
  -- Don
 
 
 
 

 --
 Ivan Lazar Miljenovic
 ivan.miljeno...@gmail.com
 IvanMiljenovic.wordpress.com


 ___
 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] Broken registration link on hackage trac

2010-01-18 Thread Ian Lynagh
On Mon, Jan 18, 2010 at 07:35:31PM +, Andy Gimblett wrote:

 I want to register an account on hackage's trac instance, but the  
 register an account link on the start page:

 http://hackage.haskell.org/trac/hackage/wiki/WikiStart

 is broken.

Fixed - thanks for the report.


Thanks
Ian

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


Re: [Haskell-cafe] Broken registration link on hackage trac

2010-01-18 Thread Gwern Branwen
On Mon, Jan 18, 2010 at 6:17 PM, Ian Lynagh ig...@earth.li wrote:
 On Mon, Jan 18, 2010 at 07:35:31PM +, Andy Gimblett wrote:

 I want to register an account on hackage's trac instance, but the
 register an account link on the start page:

 http://hackage.haskell.org/trac/hackage/wiki/WikiStart

 is broken.

 Fixed - thanks for the report.


 Thanks
 Ian

While we're fixing things, has anyone else noticed that the QuickCheck
mailing list seems to be broken?


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


[Haskell-cafe] Iteratee wrapper for attoparsec

2010-01-18 Thread Gregory Collins
John Lato jwl...@gmail.com writes:

 I don't know if I'd call it a hybrid, however there is a way to embed
 Parsec parsers (v.3 only) in iteratee.  The necessary code is
 available at:

 http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs

This post inspired me to write an iteratee wrapper for attoparsec. The
attoparsec library has an incremental parser; this means that we don't
have to use John's lookahead buffer trick, restoring the iteratee
constant-space guarantee. The downside: I don't think the attoparsec
incremental parser is capable of maintaining the source position for
error reporting.

--
{-# LANGUAGE OverloadedStrings #-}

module Data.Attoparsec.Iteratee (parserToIteratee) where

--
import qualified Data.Attoparsec.Incremental as Atto
import   Data.Attoparsec.Incremental hiding (Result(..))
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
import   Data.Iteratee
import   Data.Iteratee.WrappedByteString
import   Data.Monoid
import   Data.Word (Word8)
import   Prelude hiding (takeWhile)

-- for the examples at the bottom only
import   Control.Monad.Identity
import   Data.Char
import   Data.ByteString.Internal (w2c)

-- The principle is general enough to work for any 'StreamChunk' type (with
-- appropriate wrapping/unwrapping inserted), but I'm working with
-- WrappedByteString Word8, sorry
type Stream = StreamG WrappedByteString Word8
type Iteratee   m a = IterateeG WrappedByteString Word8 m a
type Enumerator m a = Iteratee m a - m (Iteratee m a)

-- | Convert an attoparsec 'Parser' into an 'Iteratee'.
parserToIteratee :: (Monad m) =
Parser a a
 - Iteratee m a
parserToIteratee p =
IterateeG $ \s -
let r = case s of
  (EOF Nothing)- Atto.parse p 
  (EOF (Just (Err e))) - Atto.Failed e
  (EOF (Just _))   - Atto.Failed seek not permitted
  (Chunk s')   - Atto.parse p $ fromWrap s'
in return $ Cont (runChunk r) Nothing

  where
runChunk (Atto.Failed m) = throwErr $ Err m

runChunk (Atto.Done rest r) =
IterateeG $ \s - return $ Done r (addToChunk rest s)

runChunk oldr@(Atto.Partial f) =
IterateeG $ \s -
case s of
  (EOF Nothing)  - enforceDone f
  (EOF (Just e)) - return $ Cont (throwErr e) (Just e)
  (Chunk s') - let x = fromWrap s'
k = if L.null x then oldr else f x
in return $ Cont (runChunk k) Nothing

-- you end an incremental parser by passing it the empty string
enforceDone f =
return $ case f  of
  (Atto.Failed m   ) - Cont (throwErr $ Err m) (Just $ Err m)
  (Atto.Done rest r) - Done r $ Chunk (toWrap rest)
  (Atto.Partial _  ) - Cont (throwErr eoi) (Just eoi)
  where
eoi = Err premature end of input

-- | lazy bytestring - wrapped bytestring
toWrap :: L.ByteString - WrappedByteString Word8
toWrap = WrapBS . S.concat . L.toChunks

-- | wrapped bytestring - lazy bytestring
fromWrap :: WrappedByteString Word8 - L.ByteString
fromWrap = L.fromChunks . (:[]) . unWrap

-- | tack a lazy bytestring onto the front of an iteratee 'Stream'
addToChunk :: L.ByteString - Stream - Stream
addToChunk s (EOF Nothing) = Chunk $ toWrap s
addToChunk _ x@(EOF _) = x
addToChunk s (Chunk w) = Chunk $ toWrap s `mappend` w


--
-- And a quick example

sp :: Parser r ()
sp = () $ takeWhile (isSpace . w2c)

digits :: Parser r String
digits = many1 (w2c $ satisfy (isDigit . w2c))

number :: Parser r Int
number = read $ digits

numberList :: Parser r [Int]
numberList = liftA2 (:) number (many (sp * number))

ensureEOF :: Parser r ()
ensureEOF = endOfInput | reportError
  where
reportError = do
ch - anyWord8
let msg = concat [ unexpected character '
 , [w2c ch]
 , ' ]
fail msg

numberListIter :: (Monad m) = Iteratee m [Int]
numberListIter = parserToIteratee $ numberList * ensureEOF

-- | Turn a strict bytestring into an enumerator
enumBS :: (Monad m) = S.ByteString - Enumerator m a
enumBS bs = enumPure1Chunk $ WrapBS bs

_example :: [Int]
_example = runIdentity (enumerate numberListIter = run)
  where
-- example, the source could be any enumerator
enumerate = enumBS 1000 2000 3000 4000 5000 6000 7000

_exampleWithError :: Either ErrMsg [Int]
_exampleWithError = runIdentity (enumerate numberListIter = run . checkErr)
  where
enumerate = enumBS 1000 2000 3000 4000 5000 6000 7000q

--  *Data.Attoparsec.Iteratee _example
--  [1000,2000,3000,4000,5000,6000,7000]


[Haskell-cafe] Re: Windows emulator for testing purposes

2010-01-18 Thread Günther Schmidt

Hi,

this is my configuration:

My iMac and right next to it an x86 with 8GB RAM running OpenSolaris, 
because of its ZFS.


On the OpenSolaris box are about 20 VMs with XP mostly installed, run by 
VirtualBox in headless mode. I connect to those machines from my iMac 
via Remote Desktop (available for Mac from Microsoft). Thanks to the RAM 
I can run up to 3 VMs simultaneously.


Once you installed your 1st WinXP into a Virtual Machine and have it 
activated take a ZFS snapshot of the Virtual disk image and then make 
ZFS clones from that snapshot. Use those disk images then to install 
software as you like.


They will not cost you any additional disk space initially, thanks to ZFS.

All of my devel work is done in those VMS. I suggest you do not bother 
with wine.


Günther



Am 18.01.10 21:04, schrieb Gregory Crosswhite:

Hey everyone!

I have a Linux machine and a OSX machine, and I am developing packages that I 
would like to upload to Hackage one day.  Do you have any recommendations for a 
free/open source solution that would let me emulate a Windows environment for 
testing purposes?

Cheers,
Greg




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


Re: [Haskell-cafe] Poor man's generic programming

2010-01-18 Thread Henning Thielemann

Neil Mitchell schrieb:

Hi Henning,

Uniplate might be the answer you are looking for -
http://community.haskell.org/~ndm/uniplate
  

Thanks for the pointer!

Uniplate is simple (only multi parameter type classes, and even then
only in a very simple usage), fast (one of the fastest generics
libraries) and concise (probably the most concise generics library).
It's also not as powerful as most of the other generics libraries, but
I find it does about 98% of the generics tasks I need. Uniplate is
used extensively in virtually all my tools, for example HLint.
  
Must a package import Uniplate, if it uses Uniplate generics, or is it a 
preprocessor like I sketched?

As an example, I guess your function returns all the Int's embedded
within a data type, at any level?

I abstracted the Bin example from GHC's generic extension introduction:
  
http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-classes.html


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


Re: [Haskell-cafe] FFI, C/C++ and undefined references

2010-01-18 Thread wren ng thornton

Stephen Tetley wrote:

Also binding to a C library is easier than binding to a C++ one, if
you can think of another library rather than SRILM that will meet your
needs...


Alas, SRILM really is the standard tool for this so there aren't other 
(worthwhile) options AFAIK. But it's pretty standard for people to bind 
to SRILM as though it were C, since C bindings are standardized and C++ 
is a nightmare. I haven't done the gory details myself but I sat next to 
someone who did.


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Windows emulator for testing purposes

2010-01-18 Thread Gregory Crosswhite
So, part of the problem is that I am using my own build system (Blueprint) 
rather than Cabal, which I would like to test someday to make sure it works 
under windows;  problems like screwing up the file paths are exactly the kind 
of thing that I worry about happening.  :-)

And part of the reason that I developed and am using my own build system is 
because I am mixing Fortran and Haskell code, which is something that Cabal 
does not support in any meaningful use of the word support --- i.e., I don't 
count writing a parallel configuration and build system for the Fortran code 
and grafting it onto Cabal using a complicated assortment of hooks as being a 
meaningful sense of this word.  :-)

Cheers,
Greg


On Jan 18, 2010, at 1:52 PM, Stephen Tetley wrote:

 Hello Gregory
 
 If the packages are FFI-free they should just work (ahem, perhaps
 with some caveats about e.g. file paths - if they have data files
 included).
 
 If they have FFI dependencies then a Windows emulator is going to have
 to emulate Unix in turn (either via MinGW or Cygwin). It might be more
 productive to simply label them as Untested under Windows and make a
 reference to the FFI dependencies.
 
 Best wishes
 
 Stephen
 ___
 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


[Haskell-cafe] Declarative binary protocols

2010-01-18 Thread Antoine Latter
Cafe,

We have some fantastic tools for binary parsing in packages like
binary and cereal (and presumably attoparsec, which I've not used).
But they don't quite scratch an itch I have when writing
implementations of binary communication protocols.

A good example of my problem is in my implementation of the memcached
binary wire protocol: http://hackage.haskell.org/package/starling

What I've tried to do is divide up the library into a declarative
protocol description and an imperative machine to sit on a handle and
link together a server response with the source request.

In the declarative core all of the types which come off of the wire
have an associated Data.Binary.Get action - but this isn't quite good
enough. Data.Binary works on ByteStrings, but I have a handle. I don't
want to use hGetContents because I have trouble working out when lazy
IO is and is not correct. I can't use hGet because I don't know how
much to get until I'm in the middle of the Get action.

How do other folks solve this issue?

What I've done is broken down and included (getResponse :: Handle -
IO Response) in my core protocol description module, which gets a
fixed-length header from which we can figure out how much else to get
to form the complete response. But it would be nice to have something
cleaner.

One thing I've thought of is generalizing Data.Binary.Get to operate
over either ByteStrings or Handles. But then I would be doing reads
from the handle every couple of bytes. To avoid that I could extend
the monad to include declarations of how many bytes the parser will
require, which may be declared mutliple times throughout the parser.
This felt a bit weird to me, though.

Thanks,
Antoine


Declarative core module:
http://hackage.haskell.org/packages/archive/starling/0.1.1/doc/html/Network-Starling-Core.html
IO-centric module:
http://hackage.haskell.org/packages/archive/starling/0.1.1/doc/html/Network-Starling-Connection.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread Michael Vanier
For a completely different approach, I've had good success running 
xmonad from either Ubuntu minimal (which is a bare-bones version of 
Ubuntu that few people realize exists) or Arch Linux.  In either case 
you have to spend more time setting up the system, but the results IMO 
are worth it.  I don't use gdm but use a customized .xinitrc script 
which I invoke myself through startx.


Mike

John Millikin wrote:

I've been quite happy with Ubuntu's xmonad package, though I run it
within a GNOME session.

Have you tried the instructions on the XMonad wiki for inter-operating
with GNOME? http://www.haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Gnome

On Mon, Jan 18, 2010 at 13:40, michael rice nowg...@yahoo.com wrote:
  

Perhaps. Is there a Linux distro that's more XMonad friendly?

Michael

--- On Mon, 1/18/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote:

From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com
Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
To: michael rice nowg...@yahoo.com
Cc: Don Stewart d...@galois.com, haskell-cafe@haskell.org
Date: Monday, January 18, 2010, 4:26 PM

Oh, is Fedora still using a version of GDM that doesn't let you use a
custom .Xsession (or even remember that you want to use something that
isn't called Gnome)?

michael rice nowg...@yahoo.com writes:



Well, for starters the Fedora entry for installing XMonad is blank/empty:
http://www.haskell.org/haskellwiki/Xmonad/Installing_xmonad#Fedora

Some things I've done:

I set up a .xmonad directory in my home directory with this xmonad.hs

[mich...@localhost ~]$ cat ~/.xmonad/xmonad.hs
--
-- An example, simple ~/.xmonad/xmonad.hs file.
-- It overrides a few basic settings, reusing all the other defaults.
--

import XMonad

main = xmonad $ defaultConfig
{ borderWidth= 2
, terminal   = urxvt
, normalBorderColor  = #cc
, focusedBorderColor = #cd8b00 }

[mich...@localhost ~]$

I set up a .xsession directory in my home directory with this in it

[mich...@localhost ~]$ cat .xsession
export WINDOW_MANAGER=/usr/bin/xmonad
exec gnome-session

[mich...@localhost ~]$

Because supposedly X doesn't even check .xsession file without having 
xorg-x11-xinit-session installed, I also downloaded that.

I set up a XMonad.desktop file in /usr/share/applications directory

[mich...@localhost ~]$ cat /usr/share/applications/Xmonad.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Xmonad
# change this path according to your xmonad binary
Exec=/usr/bin/xmonad
NoDisplay=true
X-GNOME-WMName=Xmonad
X-GNOME-Bugzilla-Bugzilla=XMonad
X-GNOME-Bugzilla-Product=xmonad
X-GNOME-Bugzilla-Component=general
X-GNOME-Autostart-Phase=WindowManager
X-GNOME-Provides=windowmanager
X-GNOME-Autostart-Notify=true
[mich...@localhost ~]$

I added /usr/bin/xmonad to startup applications.

All these things were suggested.

Michael

--- On Mon, 1/18/10, Don Stewart d...@galois.com wrote:

From: Don Stewart d...@galois.com
Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
To: michael rice nowg...@yahoo.com
Cc: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com, 
haskell-cafe@haskell.org
Date: Monday, January 18, 2010, 3:30 PM

nowgate:
  

I'd already found a lot of these links and tried some of their suggestions,
without any success. Does anyone who posts here actually use it (what
platform)?


What's the problem exactly?

-- Don




  

--
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com


___
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
  


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


[Haskell-cafe] Re: Declarative binary protocols

2010-01-18 Thread Antoine Latter
On Mon, Jan 18, 2010 at 10:39 PM, Antoine Latter aslat...@gmail.com wrote:
 Cafe,

 We have some fantastic tools for binary parsing in packages like
 binary and cereal (and presumably attoparsec, which I've not used).
 But they don't quite scratch an itch I have when writing
 implementations of binary communication protocols.

 A good example of my problem is in my implementation of the memcached
 binary wire protocol: http://hackage.haskell.org/package/starling

 What I've tried to do is divide up the library into a declarative
 protocol description and an imperative machine to sit on a handle and
 link together a server response with the source request.

 In the declarative core all of the types which come off of the wire
 have an associated Data.Binary.Get action - but this isn't quite good
 enough. Data.Binary works on ByteStrings, but I have a handle. I don't
 want to use hGetContents because I have trouble working out when lazy
 IO is and is not correct. I can't use hGet because I don't know how
 much to get until I'm in the middle of the Get action.


Now that I've posted I've come up with a solution.

I will start with binary-strict:Data.Binary.Strict.IncrementalGet[1]

It currently defines


data Result a
= Failed String
| Finished ByteString a
| Partial (ByteString - Result a)


Which I will change to:


data Result a
= Failed String
| Finished ByteString a
| Partial Int (ByteString - Result a)


Where the p type includes some information as to why the result is
partial. This means that I will change the current function:

suspend :: Get r ()

to:

require :: Int - Get r ()

We will then only return the 'Partial' result on a call to 'require'.
Any other attempts to read beyond the so-far fetched byte-string will
result in failure.

I'll then have a function of type:

runFromHandle :: Handle - Get r r - IO r

Which leaves the handle in a usable state and never seeks ahead in the
handle, and also a function:

runFromBytes :: ByteString - Get r r - {- some sensible return type -}

The idea is that the partial return type is hidden from the users of
the library, but we take advantage of it to read from the handle in a
sensible way.

This is all based on a quick read-through of binary-strict. But it
fits how I think about a lot of the binary protocols I write:

getResponse = do
  require 256
  x - getX
  len - getWord16be
  y - getY
  z - getZ
  require (fromIntegral len * 8)
  a - getA
  b - getB
  return $ Response x y z a b c

The only weird part is that I only ever intend to write the require
statements at the top-level - maybe 'getA' and the like can be written
in some restricted version of the Get monad which doesn't permit
'require' declarations.

Any comments? Is there an easier way to do this?

Antoine

[1] 
http://hackage.haskell.org/packages/archive/binary-strict/0.4.6/doc/html/Data-Binary-Strict-IncrementalGet.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: afv-0.0.3

2010-01-18 Thread Tom Hawkins
This release of AFV adds counter example generation for both concrete
bounded violations or for inconclusive results when the induction
fails to converge.  I also put Linux and Windows binaries here:
http://tomahawkins.org/.

http://hackage.haskell.org/package/afv

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