Re: [Haskell-cafe] Problems with iteratees

2011-02-03 Thread wren ng thornton

On 2/2/11 11:25 PM, Maciej Wos wrote:

I think the problem is that the iteratee you give to I.convStream
always returns Just [something] while you should return Nothing on
EOF.


That makes sense for the hanging problem (which I only noticed during 
debugging). Though I still get the the same error message when running 
the whole program...



On Thu, Feb 3, 2011 at 10:06 AM, wren ng thorntonw...@freegeek.org  wrote:

When I put this all together, the process is killed with:

control message: Just (Err endOfInput)

Data.Iteratee.Base.run is the origin of the control message: part of the
error, but I don't know where (Err endOfInput) is coming from since
Data.Iteratee.Base only uses (Err EOF) or (Err Divergent Iteratee). I
believe runGetEnumeratee is where the problem is, though it could also be
the use site or something in one of the libraries. Any help would be
appreciated.


--
Live well,
~wren

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


Re: [Haskell-cafe] Problems with iteratees

2011-02-03 Thread oleg

I agree with Maciej Wos' diagnosis and solution. I'd like to point out
that the Tiff library has to do a similar processing: use an iteratee
to read bytes from the outer stream and to produce elements for the
inner stream (e.g., signed 32-bit integers). In your version of the
Iteratee library, please look at Data/Iteratee/Codecs/Tiff.hs and
search for the following fragment:

  -- Read the array of long integers
  -- of 1 element: the offset field contains the value
  read_value typ e' 1 | typ == TT_long || typ == TT_slong = ...

  -- of n elements
  read_value typ e' count | typ == TT_long || typ == TT_slong = do
  offset - endianRead4 e'
  return . Just . TEN_INT $ \iter_int - return $ do
Iter.seek (fromIntegral offset)
let iter = convStream
 (liftM (either (const Nothing) (Just . (:[]) . 
conv_long typ)) (checkErr (endianRead4 e')))
 iter_int
Iter.joinI $ Iter.joinI $ Iter.takeR (4*count) iter


Of relevance is the line that contains convStream. Please notice
(const Nothing) that Maciej was talking about.

The newer version has a somewhat more convenient sequence_stream
function, which creates a nested stream using the supplied iteratee to
read from the outer stream and produce an element for the inner stream.
The function is particularly useful if you read the inner stream all
the way, until it is exhausted. Here is how the above read_value
clause looks now

-- of n elements
  read_value typ count | typ == TT_long || typ == TT_slong = do 
offset - endian_read4
let converter = endian_read4 = return . conv_long typ
return . Just . TEN_INT $ \iter_int - do
seek_stream (fromIntegral offset)
runI = takeR (4*count) (sequence_stream converter iter_int)

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


Re: [Haskell-cafe] Another Question

2011-02-03 Thread Ketil Malde
Navin Rustagi navin_ku...@yahoo.com writes:

 It gives the error ERROR - Control stack overflow. I assume it is
 because of the lazy evaluation. 

Yes, you're just building a tower of additions, and when evaluating
this, you blow up the stack.  You need to make sure to evaluate the
tuple element each time, so instead of 

case ys of  'A'  - (elf, els+1,elr,ell,elx) 

write:

case ys of  'A'  - els `seq` (elf, els+1,elr,ell,elx)

(Strictly speaking this will only evaluate the previous value, but your
 tower of additions will now have maximum one floor)

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

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


Re: [Haskell-cafe] Status update on {code, trac, projects, planet, community}.haskell.org

2011-02-03 Thread Roman Cheplyaka
* Duncan Coutts duncan.cou...@googlemail.com [2011-02-02 01:33:22+]
 These are all hosted on the community server. The community server was
 hacked on the 26th January and we took it offline. The server was
 running an old version of debian that was no longer supported with
 security updates. (Ironically, two days previously the infrastructure
 team had been discussing the fact that nobody seemed to have any time
 available to do the planned migration to a new host). The hacker
 replaced sshd which we noticed because the ssh host signature changed
 and it started prompting for passwords (we use key-based rather than
 password based logins).

Might be related:
http://sourceforge.net/blog/sourceforge-attack-full-report/

-- 
Roman I. Cheplyaka :: http://ro-che.info/
Don't worry what people think, they don't do it very often.

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


Re: [Haskell-cafe] Another Question

2011-02-03 Thread Roman Cheplyaka
Hi Navin,

next time, could you please choose more informative subject for your
emails to the mailing list? It is read by many people, and choosing a
good subject will save them a lot of time. In this case, something like
Stack overflow or How to make a function strict would do.

Thanks.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
Don't worry what people think, they don't do it very often.

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


[Haskell-cafe] Haskell procedure

2011-02-03 Thread Houdini

One :Thank you Carsten Schultz,Daniel Fischer,Mihai and all the other for
your help.
Two:After my last post I wrote some function that should help me in the
future,but I need some help with the followint as I'm tired and have to fit
in a schedule.I know it is long so I'll try and explain it as short and
consice as I can.
The DPLL procedure has two main stages: a simplification stage and a search
stage. In the simplification
stage, functions are applied to the formula to assign truth values to
certain propositional variables. The
simplifications are made because if there is a satisfying assignment for the
simplified formula then it is also
a satisfying assignment for the original formula. This reduces the need for
search which can take a long
time. The search stage is performed when no more simplifications can be
made. In this stage a literal is
chosen and is assigned true or false leading to two new branches in the
search space.
I wrote some function wich should be helpfull,but I have to fit in a
schedule and I'm getting tired I need some additional help if possible.

module Algorithm where

import System.Random
import Data.Maybe
import Data.List

type Atom = String
type Literal = (Bool,Atom)
type Clause = [Literal]
type Formula = [Clause]
type Model = [(Atom, Bool)]
type Node = (Formula, ([Atom], Model))

-- This function  takess a Clause and return the set of Atoms of that
Clause.
atomsClause :: Clause - [Atom]
   

-- This function  takes a Formula returns the set of Atoms of a Formula
atoms :: Formula - [Atom]
   

-- This function returns True if the given Literal can be found within
-- the Clause.
isLiteral :: Literal - Clause - Bool
   

-- this function takes a Model and an Atom and flip the truthvalue of
-- the atom in the model
flipSymbol :: Model - Atom - Model -- is this ok?
 
Additional functions that I wrote:
remove :: (Eq a) )a -[a] -[a]
-This function removes an item from a list.
 
 neg :: Literal-Literal
-This function flips a literal (ie. from P to :P and from :P to P).
falseClause :: Model - Clause - Bool
-This function takes a Model and a Clause and returns True
if the clause is unsatisfied by the model or False otherwise.
falseClauses :: Formula - Model - [Clause]
-This function takes a Formula and a Model and returns the list of
clauses of the  formula that are not satisfied.
 assignModel :: Model - Formula - Formula
 -This function applies the assign function for all the assignments of a
given model.
 checkFormula :: Formula - Maybe Bool This function checks whether a
formula can be  decided to be satisfiable or unsatisfiable based on the
effects of the assign function.
 satisfies :: Model - Formula -. Bool This function checks whether a
model satisfies a formula. This is done with the combination of the
assignModel and checkFormula functions.


--Where do I need help:
   
   removeTautologies :: Formula-Formula
This function should output a simplified formula if tautologies
can be found in one or more clauses in the input
Notes: If in a clause, a literal and its negation are found, it means that
the clause will be true, regardless of the value
finally assigned to that propositional variable. Consider the following
example:
(A v B v -A) ^ (B v C v A)
The first clause contains the literals A and -A. This means that the clause
will always be true, in which case
it can be simplify the whole set to simply (B v C v A) (the second clause
alone)

 pureLiteralDeletion :: Formula-Formula
This function is suppose to implement a simplification step that assumes as
true any atom in a formula that appears exclusively in a positive or
negative form (not both). Consider the formula:
(P v Q v R) ^ (P v Q v -R) ^ (-Q v R)
Note that in this formula P is present but -P is not. Using Pure Literal
Deletion  it can be assumed that the value of P will be True thus
simplifying the formula to (-Q v R). If the literal were false then the
literal would simply be deleted from the clauses it appears in. In that case
any satisfying model for the resulting formula would also be a satisfying
model for the formula when we assume that the literal is true. Hence this
simplification is sound in that if there is a solution to the simplified
formula then there is a solution to the original formula.
   
  propagateUnits :: Formula-Formula
If a clause in a propositional formula contains only one literal, then that
literal must be true (so that the particular clause can be satisfied). When
this happens,we can remove the unit clauses (the ones that contain only one
literal), all the clauses where the literal appears and also, from the
remaining clauses, we can delete the negation of the literal (because if P
is true, -P will be false).For example, in the formula (P v Q v R) ^ (-P v Q
v -R) ^ (P) we have one unit clause (the third clause(P) ). Because this 

[Haskell-cafe] How to #include into .lhs files?

2011-02-03 Thread Conal Elliott
Does anyone have a working example of #include'ing Haskell code into a
bird-tracks-style .lhs file with GHC? Every way I try leads to parsing
errors. Is there documentation about how it's supposed to work?

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


[Haskell-cafe] problem with instance method

2011-02-03 Thread Patrick Browne
Hi,
I am studying type classes using examples from the literature [1].
The attached code is a formalization of basic object oriented ideas. The
particular approach seems to be built on the concepts of: thing, object,
and identifier.
I have no intension to implement anything or significantly change the
code below. Rather, I am trying to understand the code as it stands.
I include a number of test runs which seem OK, but I cannot get the
*obj* function to work.

obj :: t - i - o t i
obj t i = Obj t i

Any hints would be appreciated.

Thanks,
Pat

[1]
ftp://ftp.geoinfo.tuwien.ac.at/frank/frank97executableAxiomaticSpecification.pdf



-- A property of a thing
data Color = Blue | Green | Red | White deriving Show

-- A thing
class Cars c where
 car :: Color - c
 getColor :: c - Color
 putColor :: Color - c - c
 paint :: Color - c - c
 paint color car = putColor color car

data Car = Car Color deriving Show


instance Cars Car where
 car c = Car c
 putColor color (Car c) = Car color
 getColor (Car c) = c


-- Identifiers for objects
class (Integral i) = IDs i where
 startId :: i
 newId :: i - i
 newId i = succ i
 sameId, notSameId :: i - i - Bool
 sameId i j = i == j
 notSameId i j = not (sameId i j)

instance IDs Integer where
 startId = 1

-- Objects consist of Things, with Identifiers
class (IDs i,  Show i) = Objects o t i where
 obj :: t - i - o t i
 getId :: o t i - i
 getThing :: o t i - t
 doThing :: (t - t) - o t i - o t i
 doThing f o = obj (f (getThing o)) (getId o)
 same :: o t i - o t i - Bool
 same i j = sameId (getId i) (getId j)
 isId :: i - o t i - Bool
 isId i o = sameId i (getId o)




-- A general type of Obj
data Object t i = Obj t i deriving  Show


-- A particular Car Obj, which an instance of Objects class (in Haskell
terms, not OO terms)
instance Objects Object Car Integer where
 obj t i = Obj t i
 getId (Obj t i) = i
 getThing (Obj t i) = t

-- Create some actual Objects
x = (Obj (Car Blue) (startId::Integer))
y = (Obj (Car Green) (newId startId::Integer))



-- Some tests on car thing, seem OK
--   getColor (Car Blue)
--   putColor Green (Car Blue)
--   getColor (putColor Green (Car Blue))
-- Some tests on objects, seem OK
--  same x y
-- Obj (Car Blue) (newId startId::Integer)
-- Obj (Car Blue) (startId::Integer)
-- getThing (Obj (Car Blue) (startId::Integer))
-- getId (Obj (Car Blue) (startId::Integer))
-- isId 2 (Obj (Car Blue) (startId::Integer))

This message has been scanned for content and viruses by the DIT Information 
Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie

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


Re: [Haskell-cafe] problem with instance method

2011-02-03 Thread Ivan Lazar Miljenovic
On 3 February 2011 21:09, Patrick Browne patrick.bro...@dit.ie wrote:
 Hi,
 I am studying type classes using examples from the literature [1].
 The attached code is a formalization of basic object oriented ideas. The
 particular approach seems to be built on the concepts of: thing, object,
 and identifier.
 I have no intension to implement anything or significantly change the
 code below. Rather, I am trying to understand the code as it stands.
 I include a number of test runs which seem OK, but I cannot get the
 *obj* function to work.

 obj :: t - i - o t i
 obj t i = Obj t i

The type signature says Given any `t' and any `i', this will return
any `o t i' (for some unspecified type `o').  However, your actual
implementation uses a specific data-type, namely Object for `o'.
Change the type signature to be obj :: t - i - Object t i.

-- 
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] Inheritance and Wrappers

2011-02-03 Thread Ozgur Akgun
On 3 February 2011 02:35, Brandon Moore brandon_m_mo...@yahoo.com wrote:

 Here's one thing to consider:

 Can you write a function

 f :: (Data a) = a - String
 f x = termTag x

 It would seem the Data a = Term a instance justifies
 this function, and it will always use the default instance.

 Now, what happens if f is applied to a value of some type
 T which is an instance of Data, but has a custom Term instance?


Great point, thanks!

I guess somehow you shouldn't be allowed to write that function f. I need
to think about this one.

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


Re: [Haskell-cafe] problem with instance method

2011-02-03 Thread Tom Nielsen
No, obj is a method of the Objects class. you've already declared it
in the instance of Objects Object

your code works just fine here. adding:

 mycar = Car Blue

 o:: Object Car Integer
 o = obj mycar 4

ghci says...

*Objects :t obj
obj :: (Objects o t i) = t - i - o t i
*Objects o
Obj (Car Blue) 4

But I hope you read my last email in the other thread you started...

Tom

On Thu, Feb 3, 2011 at 10:15 AM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 On 3 February 2011 21:09, Patrick Browne patrick.bro...@dit.ie wrote:
 Hi,
 I am studying type classes using examples from the literature [1].
 The attached code is a formalization of basic object oriented ideas. The
 particular approach seems to be built on the concepts of: thing, object,
 and identifier.
 I have no intension to implement anything or significantly change the
 code below. Rather, I am trying to understand the code as it stands.
 I include a number of test runs which seem OK, but I cannot get the
 *obj* function to work.

 obj :: t - i - o t i
 obj t i = Obj t i

 The type signature says Given any `t' and any `i', this will return
 any `o t i' (for some unspecified type `o').  However, your actual
 implementation uses a specific data-type, namely Object for `o'.
 Change the type signature to be obj :: t - i - Object t i.

 --
 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] How to #include into .lhs files?

2011-02-03 Thread Daniel Fischer
On Thursday 03 February 2011 10:33:23, Conal Elliott wrote:
 Does anyone have a working example of #include'ing Haskell code into a
 bird-tracks-style .lhs file with GHC? Every way I try leads to parsing
 errors. Is there documentation about how it's supposed to work?

 Help much appreciated.   - Conal

Stupid example:

-- Main:

 {-# LANGUAGE CPP #-}
 module Main (main) where

#include MachDeps.h

 main :: IO ()
 main = do

#if WORD_SIZE_IN_BITS == 32

 putStrLn 32 bits

#include Stuff32

# else

 putStrLn 64 bits

#include Stuff64
#endif

-- Stuff32:

  putStrLn Included from Stuff32

-- Stuff64:

  putStrLn Included from Stuff64


It's a bit tricky. Since the C preprocessor is run after the unlit, the 
included code should not have bird-tracks, also you have to get the 
indentation right. There's probably a way to run cpp before unlit, which 
would allow you to have bird-tracks in the #include'd code.

Much easier with LaTeX-style literate code.

Cheers,
Daniel

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


[Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread C K Kashyap
Hi,
I've been working on a Haskell based platform independent graphics rendering
using VNC. I'd like it very much if you could take a look at it and give me
feedback. Using it is straight forward -

git clone g...@github.com:ckkashyap/Chitra.git
cd Chitra
make
./Main 100 100 5900

Main starts off a vncserver listening on port 5900. A standard vncviewer can
be
used to connect to 'localhost' and you can see a 100 x 100 screen. Clicking
on
the screen will set the pixel on the click location.

What I eventually want to do is somehow integrate this piece with GHCI in
such
a manner that one can use GHCI to draw things on the VNC buffer.

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


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread Krzysztof Skrzętnicki
One thing to notice:
$ cabal install network-server

is needed.

Best regards,
Krzysztof Skrzętnicki

On Thu, Feb 3, 2011 at 12:15, C K Kashyap ckkash...@gmail.com wrote:

 Hi,
 I've been working on a Haskell based platform independent graphics
 rendering
 using VNC. I'd like it very much if you could take a look at it and give me
 feedback. Using it is straight forward -

 git clone g...@github.com:ckkashyap/Chitra.git
 cd Chitra
 make
 ./Main 100 100 5900

 Main starts off a vncserver listening on port 5900. A standard vncviewer
 can be
 used to connect to 'localhost' and you can see a 100 x 100 screen. Clicking
 on
 the screen will set the pixel on the click location.

 What I eventually want to do is somehow integrate this piece with GHCI in
 such
 a manner that one can use GHCI to draw things on the VNC buffer.

 Regards,
 Kashyap


 ___
 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] Status update on {code, trac, projects, planet, community}.haskell.org

2011-02-03 Thread Duncan Coutts
On Thu, 2011-02-03 at 10:37 +0200, Roman Cheplyaka wrote:
 * Duncan Coutts duncan.cou...@googlemail.com [2011-02-02 01:33:22+]
  These are all hosted on the community server. The community server was
  hacked on the 26th January and we took it offline. The server was
  running an old version of debian that was no longer supported with
  security updates. (Ironically, two days previously the infrastructure
  team had been discussing the fact that nobody seemed to have any time
  available to do the planned migration to a new host). The hacker
  replaced sshd which we noticed because the ssh host signature changed
  and it started prompting for passwords (we use key-based rather than
  password based logins).
 
 Might be related:
 http://sourceforge.net/blog/sourceforge-attack-full-report/

Yes, it's quite possible.

One difference to note is that we use ssh key based logins, not
passwords. We suspect this saved us from the worst case scenarios.

Nevertheless, while we don't have to reset passwords, we are concerned
about the potential that the attacker replaced or added to users
~/.ssh/authorized_keys lists, which is why we have not yet re-enabled
user accounts.

We will try and provide as full a picture as we can when we're satisfied
we've got as much info and confidence as we're likely to get.

Duncan


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


Re: [Haskell-cafe] Problems with iteratees

2011-02-03 Thread John Lato

 From: wren ng thornton w...@freegeek.org
 On 2/2/11 11:25 PM, Maciej Wos wrote:
  I think the problem is that the iteratee you give to I.convStream
  always returns Just [something] while you should return Nothing on
  EOF.

 That makes sense for the hanging problem (which I only noticed during
 debugging). Though I still get the the same error message when running
 the whole program...


I don't have too much to add to Maciej and Oleg's reply, except that I'd
recommend looking at the Wave codec over the Tiff reader in those versions
of iteratee.  I don't think that's the only problem, though, because then
you'd be getting a Divergent iteratee error.

The endOfInput error is suspicious, and I think you'll need to track it
down to solve this problem.  It doesn't appear to be from either iteratee or
protocol-buffers.  Could it be coming from your IO library?  I wonder if the
enumerator is trying to force a read after EOF has been reached for some
reason?

As an experiment, you could try using a custom convStream function like
this:

convStream2 :: Monad m =  IterateeG s el m (Maybe (s' el')) -
EnumeratorN s el s' el' m aconvStream2 fi iter = fi = check  where
check (Just xs) = lift (runIter iter (Chunk xs)) = docase  check
(Nothing) = return iter  docase (Done a _)= return . return $
a  docase (Cont k Nothing)  = convStream2 fi k

  docase (Cont k (Just endOfInput)) = convStream2 (return Nothing) k
 docase (Cont _ (Just e)) = return $ throwErr e

This may help determine if it's a problem with IO or with the message
parsing.

John


  On Thu, Feb 3, 2011 at 10:06 AM, wren ng thorntonw...@freegeek.org
  wrote:
  When I put this all together, the process is killed with:
 
  control message: Just (Err endOfInput)
 
  Data.Iteratee.Base.run is the origin of the control message: part of
 the
  error, but I don't know where (Err endOfInput) is coming from since
  Data.Iteratee.Base only uses (Err EOF) or (Err Divergent Iteratee).
 I
  believe runGetEnumeratee is where the problem is, though it could also
 be
  the use site or something in one of the libraries. Any help would be
  appreciated.

 --
 Live well,
 ~wren

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


Re: [Haskell-cafe] Yesod and concurrency

2011-02-03 Thread Ertugrul Soeylemez
Michael Snoyman mich...@snoyman.com wrote:

 On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez e...@ertes.de wrote:

  how well do WAI, Yesod and the 'persistent' package play with
  concurrency?  For example, I'd like to write a program, which
  concurrently provides two related sites as well as a few background
  workers, which do something with the database.  My idea would look
  something like this:
 
   main :: IO ()
   main =
     withMyAppPool $ \pool - do
       forkIO $ worker1 ...   -- background worker
       forkIO $ worker2 ...   -- background worker
       forkIO $ worker3 ...   -- background worker
       forkIO $ toWaiApp ...  -- site 1
       forkIO $ toWaiApp ...  -- site 2
 
  Will I run into problems with this?

 There should not be any issues, just make sure you compile with
 -threaded. The persistent database connection pool should work just
 fine for this. If you find any issues, please let me know, but I have
 not had trouble in the past.

I've run into the first problem with this.  Without having to use
subsites, what's an easy method to use wai-handler-devel with such a
setup?


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife = sex)
http://ertes.de/



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


[Haskell-cafe] PhD Studentships in Functional Programming, Nottingham

2011-02-03 Thread Henrik Nilsson

Apologies for multiple copies.

Best,

/Henrik

--
Henrik Nilsson
School of Computer Science
The University of Nottingham
n...@cs.nott.ac.uk
+--+

 PhD Studentships in Functional Programming

School of Computer Science
   University of Nottingham, UK

The Functional Programming Lab (FP Lab) in the School of Computer
Science at the University of Nottingham is seeking to appoint up
to two new PhD students, starting on 1st October 2011.

The topics for the studentships are open, but will be within the
general area of functional programming.  The studentships are for
3.5 years, include a maintenance grant of 13,590 UK pounds per
year and UK/EU tuition fees, and are open to UK and EU applicants.
Particularly strong candidates from outside the EU may also be
considered, subject to additional funds being available.

Applicants will require a first-class Honours degree (or equivalent)
in Computer Science, Mathematics, and/or Physics, experience in
functional programming, and an aptitude for mathematical subjects.
A higher degree (e.g. Masters) would be desirable.  Additionally,
experience in one or more of the following will be particularly
welcome: formal semantics, type theory, program verification,
theorem provers, domain-specific languages, languages for physical
modelling, programming language implementation and tools.

Successful applicants will work under the supervision of Dr Graham
Hutton or Dr Henrik Nilsson in the FP Lab in Nottingham, a leading
centre for research on functional programming.  The group currently
comprises 5 academic staff, 1 research fellow, and 10 PhD students.

In order to apply, please submit the following to Dr Graham Hutton
(g...@cs.nott.ac.uk) or Dr Henrik Nilsson (n...@cs.nott.ac.uk) by 1st
March 2011: an up-to-date copy of your CV (including the results
of all your University examinations to date) along with a brief
covering letter that describes your experience in functional
programming, your reasons for wishing to pursue a PhD in this area,
and any ideas you have regarding possible research directions.

Note: applicants to the FP Lab should follow the procedure above,
rather than applying directly to the School or University, e.g.
in response to a general advert for PhD studentships.

Closing date for applications: 1st March 2011.

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


Re: [Haskell-cafe] Yesod and concurrency

2011-02-03 Thread Michael Snoyman
On Thu, Feb 3, 2011 at 3:14 PM, Ertugrul Soeylemez e...@ertes.de wrote:
 Michael Snoyman mich...@snoyman.com wrote:

 On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez e...@ertes.de wrote:

  how well do WAI, Yesod and the 'persistent' package play with
  concurrency?  For example, I'd like to write a program, which
  concurrently provides two related sites as well as a few background
  workers, which do something with the database.  My idea would look
  something like this:
 
   main :: IO ()
   main =
     withMyAppPool $ \pool - do
       forkIO $ worker1 ...   -- background worker
       forkIO $ worker2 ...   -- background worker
       forkIO $ worker3 ...   -- background worker
       forkIO $ toWaiApp ...  -- site 1
       forkIO $ toWaiApp ...  -- site 2
 
  Will I run into problems with this?

 There should not be any issues, just make sure you compile with
 -threaded. The persistent database connection pool should work just
 fine for this. If you find any issues, please let me know, but I have
 not had trouble in the past.

 I've run into the first problem with this.  Without having to use
 subsites, what's an easy method to use wai-handler-devel with such a
 setup?

I believe the new architecture in use for wai-handler-devel 0.2 (which
will work with Yesod 0.7) should work properly with multi-threaded
apps. But yes, there's no easy way to do this with the current
wai-handler-devel.

Michael

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


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread Ryan Yates
Hi Kashyap,

What a fun project!  I was able to build and run on Windows (GHC 6.12.3 and
TightVNC 1.4.4) with a few minor changes:

Remove from Chitra\Canvas.hs

import Network.Server
import Network.Socket

I think these are artifacts from a previous version and are not used.  For
whatever reason getAddrInfo with the parameters given in RFB\Server.hs
 returns some IPv6 address on my system.  Changing the second parameter from
Nothing to (Just 127.0.0.1) made things work for me.

Attached is the Cabal file I used to build (it wasn't clear what license
things are under so those fields are commented out).

Ryan Yates


On Thu, Feb 3, 2011 at 6:15 AM, C K Kashyap ckkash...@gmail.com wrote:

 Hi,
 I've been working on a Haskell based platform independent graphics
 rendering
 using VNC. I'd like it very much if you could take a look at it and give me
 feedback. Using it is straight forward -

 git clone g...@github.com:ckkashyap/Chitra.git
 cd Chitra
 make
 ./Main 100 100 5900

 Main starts off a vncserver listening on port 5900. A standard vncviewer
 can be
 used to connect to 'localhost' and you can see a 100 x 100 screen. Clicking
 on
 the screen will set the pixel on the click location.

 What I eventually want to do is somehow integrate this piece with GHCI in
 such
 a manner that one can use GHCI to draw things on the VNC buffer.

 Regards,
 Kashyap


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




Chitra.cabal
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread Christian Maeder
Am 03.02.2011 12:15, schrieb C K Kashyap:
 Hi,
 I've been working on a Haskell based platform independent graphics rendering
 using VNC. I'd like it very much if you could take a look at it and give me
 feedback. Using it is straight forward -
 
 git clone g...@github.com:ckkashyap/Chitra.git

This step failed for me with:

maeder@leibniz:/local/maeder git clone g...@github.com:ckkashyap/Chitra.git
Initialized empty Git repository in /local/maeder/Chitra/.git/
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
maeder@leibniz:/local/maeder git --version
git version 1.7.1

What permission is needed?
Christian

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


[Haskell-cafe] OSX i386/x86 and x86_64 - time to switch supported platforms?

2011-02-03 Thread Max Cantor
I originally posted this on haskell-GHC-users, but was curious how the wider 
community felt.

The last 32-bit, Intel Mac was the Mac Mini, discontinued in August 2007. The 
bulk of them were discontinued in 2006, along with PowerPC Macs.  Does it make 
sense to relegate OSX x86_64 to community status while the 32-bit version is 
considered a supported platform?  

Given that I'm far from experienced enough to be able to contribute 
meaningfully to GHC, I'm not complaining about anyone's efforts, just that 
those efforts might be a bit misallocated.  I'd venture a guess that far more 
people are interested in running 64-bit GHC on OSX than in running GHC on what 
is now fairly antiquated hardware.

mc



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


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread C K Kashyap


 maeder@leibniz:/local/maeder git clone g...@github.com:
 ckkashyap/Chitra.git
 Initialized empty Git repository in /local/maeder/Chitra/.git/
 Permission denied (publickey).
 fatal: The remote end hung up unexpectedly
 maeder@leibniz:/local/maeder git --version
 git version 1.7.1

 What permission is needed?
 Christian


Oops, you can use git://github.com/ckkashyap/Chitra.git  - sorry about that.
You can also visit https://github.com/ckkashyap/Chitra

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


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread Ryan Yates
I think you want:

git clone git://github.com/ckkashyap/Chitra.git



On Thu, Feb 3, 2011 at 10:50 AM, Christian Maeder
christian.mae...@dfki.dewrote:

 Am 03.02.2011 12:15, schrieb C K Kashyap:
  Hi,
  I've been working on a Haskell based platform independent graphics
 rendering
  using VNC. I'd like it very much if you could take a look at it and give
 me
  feedback. Using it is straight forward -
 
  git clone g...@github.com:ckkashyap/Chitra.git

 This step failed for me with:

 maeder@leibniz:/local/maeder git clone g...@github.com:
 ckkashyap/Chitra.git
 Initialized empty Git repository in /local/maeder/Chitra/.git/
 Permission denied (publickey).
 fatal: The remote end hung up unexpectedly
 maeder@leibniz:/local/maeder git --version
 git version 1.7.1

 What permission is needed?
 Christian

 ___
 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] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread C K Kashyap


 Attached is the Cabal file I used to build (it wasn't clear what license
 things are under so those fields are commented out).


 Thanks a ton Rayan ... I am glad you liked it.
I've checked in the cabal file - I am not familiar with it though ... how
exactly can I use it to build the project?

Also, do you have an idea how it can be incorporated into GHCI - As in, the
program should do a forkIO and in one thread, handle network and on the
other prompt an interactive ghci shell that'll let one modify the screen
buffer in an expressive way in haskell!

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


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread Christian Maeder
Am 03.02.2011 17:20, schrieb C K Kashyap:
 Oops, you can use git://github.com/ckkashyap/Chitra.git
 http://github.com/ckkashyap/Chitra.git  - sorry about that.
 You can also visit https://github.com/ckkashyap/Chitra

Thanks, I cannot get it to run with my vncviewer (TightVNC Viewer
version 1.3.9)

How should I call vncviewer and your Main binary?

Cheers Christian

P.S. after getArgs in Main.hs use
  case args of
[x, y, p] - ...
_ - putStrLn usage: Main xres yres port

  instead of !!

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


[Haskell-cafe] ANNOUNCE: Database Supported Haskell (DSH)

2011-02-03 Thread George Giorgidze
I am pleased to announce that Database Supported Haskell (DSH) has been
released on Hackage [1].

DSH is a Haskell library for database-supported program execution. Using this
library a relational database management system (RDBMS) can be used as a
coprocessor for the Haskell programming language, especially for those program
fragments that carry out data-intensive and data-parallel computation.

Database executable program fragments can be written using the list
comprehension notation (with modest syntax changes due to quasiquoting) and
list processing combinators from the Haskell list prelude. Note that rather
than embedding a relational language into Haskell, we turn idiomatic Haskell
programs into SQL queries.

DSH faithfully represents list order and nesting, and compiles the list
processing combinators into relational queries. The implementation avoids
unnecessary data transfer and context switching between the database
coprocessor and the Haskell runtime by ensuring that the number of generated
relational queries is only determined by the program fragment's type and not
by the database size.

DSH can be used to allow existing Haskell programs to operate on large scale
data (e.g., larger than the available heap) or query existing database
resident data with Haskell.

Note that this package is flagged experimental and therefore not suited for
production use. This is a proof of concept implementation only. To learn more
about DSH, our paper entitled as Haskell boards the Ferry: Database-supported
program execution for Haskell is a recommended reading [2]. The package
includes a couple of examples that demonstrate how to use DSH.

[1] http://hackage.haskell.org/package/DSH

[2] 
http://www-db.informatik.uni-tuebingen.de/files/publications/ferryhaskell.pdf



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


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread C K Kashyap


 Thanks, I cannot get it to run with my vncviewer (TightVNC Viewer
 version 1.3.9)

 How should I call vncviewer and your Main binary?


./Main 200 200 5900

after this, the program should start listening to port 5900

You can check if things are fine by telneting to localhost:5900, you should
see this -

ck@ck-desktop:~/lab/Chitra$ telnet localhost 5900
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
RFB 003.003

After this, you can use vncviewer to connect to localhost (5900 is the
default port for vnc)



 P.S. after getArgs in Main.hs use
  case args of
[x, y, p] - ...
_ - putStrLn usage: Main xres yres port

  instead of !!


Thanks Christian ... I've incorporated this.

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


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread Christian Maeder
Am 03.02.2011 18:05, schrieb C K Kashyap:
 ck@ck-desktop:~/lab/Chitra$ telnet localhost 5900
 Trying ::1...
 Trying 127.0.0.1...
 Connected to localhost.
 Escape character is '^]'.
 RFB 003.003
 
 After this, you can use vncviewer to connect to localhost (5900 is the
 default port for vnc)

Right, a window seems to pop up very shortly before it fails for me as
shown below:

Cheers Christian

maeder@leibniz:~ vncviewer localhost
Connected to RFB server, using protocol version 3.3
No authentication needed
Desktop name Haskell Framebuffer
VNC server default format:
  32 bits per pixel.
  Most significant byte first in each pixel.
  True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
Warning: Cannot convert string
-*-helvetica-bold-r-*-*-16-*-*-*-*-*-*-* to type FontStruct
Using default colormap which is TrueColor.  Pixel format:
  32 bits per pixel.
  Least significant byte first in each pixel.
  True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
ShmCleanup called
Using shared memory PutImage
Same machine: preferring raw encoding
Unknown message type 120 from VNC server
ShmCleanup called

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


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread Christian Maeder
Maybe these messages are also important?

Client Said :: RFB 003.003
Sharing enabled
SET PIXEL FORMAT called
bpp = 32
depth = 24
big endian = 0
trueColor = 1
RED MAX = 255
GREEN MAX = 255
blueMax = 255
red shift = 16
green shift = 8
blue shift = 0

SetEncodings Command
14
0
FrameBufferUpdateRequest x=0, y=0 width =1, height=1
FrameBufferUpdateRequest x=1, y=0 width =99, height=1
FrameBufferUpdateRequest x=0, y=1 width =100, height=99
Main: socket: 7: hPutBuf: resource vanished (Connection reset by peer)


Am 03.02.2011 18:43, schrieb Christian Maeder:
 Am 03.02.2011 18:05, schrieb C K Kashyap:
 ck@ck-desktop:~/lab/Chitra$ telnet localhost 5900
 Trying ::1...
 Trying 127.0.0.1...
 Connected to localhost.
 Escape character is '^]'.
 RFB 003.003

 After this, you can use vncviewer to connect to localhost (5900 is the
 default port for vnc)
 
 Right, a window seems to pop up very shortly before it fails for me as
 shown below:
 
 Cheers Christian
 
 maeder@leibniz:~ vncviewer localhost
 Connected to RFB server, using protocol version 3.3
 No authentication needed
 Desktop name Haskell Framebuffer
 VNC server default format:
   32 bits per pixel.
   Most significant byte first in each pixel.
   True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
 Warning: Cannot convert string
 -*-helvetica-bold-r-*-*-16-*-*-*-*-*-*-* to type FontStruct
 Using default colormap which is TrueColor.  Pixel format:
   32 bits per pixel.
   Least significant byte first in each pixel.
   True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
 ShmCleanup called
 Using shared memory PutImage
 Same machine: preferring raw encoding
 Unknown message type 120 from VNC server
 ShmCleanup called

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


[Haskell-cafe] Haskell Functions

2011-02-03 Thread Manolache Andrei-Ionut


I need help with two functionsfirst this is the curent code 
:http://pastebin.com/UPATJ0r
-Function 1)removeTautologies :: Formula-Formula 
If in a clause, a literal and its negation are found, it means that the clause 
will be true, regardless of the value
finally assigned to that propositional variable. Consider the following example:
(A v B v -A) ^ (B v C v A)
The first clause contains the literals A and -A. This means that the clause 
will always be true, in which case
it can be simplify the whole set to simply (B v C v A) .
I was tinking of using something like
 removeTautologies (f:fs)=filter rTf:removeTautologies fs
 
 where rT-is supposed to take the firs Literal from the clasue and 
search for a similar one,if one si found we compare the values if not 
the we go to the second literal.
-Function 2)pureLiteralDeletion :: Formula-Formula
This is a little bit complicate but from What I get this function is suppose to 
implement a simplification step that assumes 
as true any atom in a formula that appears exclusively in a positive or
negative form (not both). Consider the formula:
(P v Q v R) ^ (P v Q v -R) ^ (-Q v R)
Note that in this formula P is present but -P is not. Using Pure Literal
 Deletion  it can be assumed that the value of P will be True thus 
simplifying the formula to (-Q v R). If the literal were false then the 
literal would simply be deleted from the clauses it appears in. In that 
case any satisfying model for the resulting formula would also be a 
satisfying model for the formula when we assume that the literal is true.


  


  


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


[Haskell-cafe] hsmagick on OSX 10.6

2011-02-03 Thread Max Cantor
Just out of curiosity, has anyone gotten this to work?  I'm getting bus errors 
whenever I call readImage.  

If anyone out there has gotten it working and would tell me which versions 
they're using of the relevant bits, that would be very much appreciated.  Also, 
I'll post all my debug info if there's someone who's gotten this to work.


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


Re: [Haskell-cafe] Haskell Functions

2011-02-03 Thread Ozgur Akgun
On 3 February 2011 18:33, Manolache Andrei-Ionut andressocrate...@yahoo.com
 wrote:

 first this is the curent code :http://pastebin.com/UPATJ0r


There is no code on that page. (It has expired, probably?)

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


[Haskell-cafe] Reader monad wrapping State monad

2011-02-03 Thread michael rice
Given the first program, it seems that the unchanging first element of the 
tuple could be handled by a Reader monad, leading to the second program, where 
b becomes the state, but how do I get the constant a from the Reader monad?

Michael 

==

import Control.Monad.State

type GeneratorState = State (Double,Double)

sqrtST :: GeneratorState Double
sqrtST = do (a,b0) - get
    let b1 = (b0**2.0+a)/(2.0*b0)
    (if (abs (a-b1**2.0))  0.01
  then
    return b1
  else do
    put (a,b1)
    sqrtST)

mySqrt a = let b = a/2.0
   in fst ( runState sqrtST (a,b) )

{-
*Main mySqrt 2.0
1.4142135623746899
-}

==

import Control.Monad.Reader
import Control.Monad.State

type GeneratorState = State Double

sqrtST :: GeneratorState Double
sqrtST = do b0 - get
    let a = ?
    b1 = (b0**2.0+a)/(2.0*b0)
    (if (abs (a-b1**2.0))  0.01
  then
    return b1
  else do
    put b1
    sqrtST)


mySqrt a = let b = a/2.0
   in runReaderT (runState sqrtST b) a




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


Re: [Haskell-cafe] Reader monad wrapping State monad

2011-02-03 Thread Thomas Davie
Is the idea here merely an exercise in using the state monad?  This can be 
easily performed using pure code.

Bob

On 3 Feb 2011, at 19:18, michael rice wrote:

 Given the first program, it seems that the unchanging first element of the 
 tuple could be handled by a Reader monad, leading to the second program, 
 where b becomes the state, but how do I get the constant a from the Reader 
 monad?
 
 Michael 
 
 ==
 
 import Control.Monad.State
 
 type GeneratorState = State (Double,Double)
 
 sqrtST :: GeneratorState Double
 sqrtST = do (a,b0) - get
 let b1 = (b0**2.0+a)/(2.0*b0)
 (if (abs (a-b1**2.0))  0.01
   then
 return b1
   else do
 put (a,b1)
 sqrtST)
 
 mySqrt a = let b = a/2.0
in fst ( runState sqrtST (a,b) )
 
 {-
 *Main mySqrt 2.0
 1.4142135623746899
 -}
 
 ==
 
 import Control.Monad.Reader
 import Control.Monad.State
 
 type GeneratorState = State Double
 
 sqrtST :: GeneratorState Double
 sqrtST = do b0 - get
 let a = ?
 b1 = (b0**2.0+a)/(2.0*b0)
 (if (abs (a-b1**2.0))  0.01
   then
 return b1
   else do
 put b1
 sqrtST)
 
 
 mySqrt a = let b = a/2.0
in runReaderT (runState sqrtST b) a
 
 
 ___
 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] Reader monad wrapping State monad

2011-02-03 Thread Daniel Fischer
On Thursday 03 February 2011 20:18:43, michael rice wrote:
 Given the first program, it seems that the unchanging first element of
 the tuple could be handled by a Reader monad, leading to the second
 program, where b becomes the state, but how do I get the constant a from
 the Reader monad?

You need a monad-transformer to use both, Reader and State.
You can use either

ReaderT Double (State Double)

or

StateT Double (Reader Double)

(they're isomorphic).

Then you can query the modifiable state with get (from the MonadState 
class) and the immutable with ask (from the MonadReader class)

type Heron = StateT Double (Reader Double)

sqrtH :: Heron Double
sqrtH = do
  a - ask
  b - get
  let c = 0.5*(b + a/b)
  if (good enough)
then return c
else put c  sqrtH

mySqrt a = runReader (evalStateT sqrtH (a*0.5)) a


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


Re: [Haskell-cafe] Reader monad wrapping State monad

2011-02-03 Thread Ozgur Akgun
On 3 February 2011 19:18, michael rice nowg...@yahoo.com wrote:

 but how do I get the constant a from the Reader monad?


http://hackage.haskell.org/packages/archive/transformers/latest/doc/html/Control-Monad-Trans-Reader.html#v:ask

You also need to change the type to use ReaderT.

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


Re: [Haskell-cafe] Haskell Functions

2011-02-03 Thread Ozgur Akgun
(CCing haskell-cafe again)

Is this an homework question?

On 3 February 2011 20:30, Manolache Andrei-Ionut andressocrate...@yahoo.com
 wrote:

  http://pastebin.com/GxQBh3hx http://pastebin.com/GxQBh3hx

 --- On *Thu, 2/3/11, Ozgur Akgun ozgurak...@gmail.com* wrote:


 From: Ozgur Akgun ozgurak...@gmail.com
 Subject: Re: [Haskell-cafe] Haskell Functions
 To: Manolache Andrei-Ionut andressocrate...@yahoo.com
 Cc: haskell-cafe@haskell.org
 Date: Thursday, February 3, 2011, 10:59 AM


 On 3 February 2011 18:33, Manolache Andrei-Ionut 
 andressocrate...@yahoo.comhttp://mc/compose?to=andressocrate...@yahoo.com
  wrote:

 first this is the curent code :http://pastebin.com/UPATJ0r


 There is no code on that page. (It has expired, probably?)

 --
 Ozgur Akgun





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


Re: [Haskell-cafe] Reader monad wrapping State monad

2011-02-03 Thread michael rice
Hi Daniel,

Ok, but what I was looking for was ReaderT on top, State on the bottom. This is 
very confusing material, with no apparent conceptual commonality (ad hoc comes 
to mind) among the many examples I've looked at. Sometimes lift is used, other 
times a lift helper function, and in this case no use of lift at all.

Michael

--- On Thu, 2/3/11, Daniel Fischer daniel.is.fisc...@googlemail.com wrote:

From: Daniel Fischer daniel.is.fisc...@googlemail.com
Subject: Re: [Haskell-cafe] Reader monad wrapping State monad
To: haskell-cafe@haskell.org
Cc: michael rice nowg...@yahoo.com
Date: Thursday, February 3, 2011, 2:54 PM

On Thursday 03 February 2011 20:18:43, michael rice wrote:
 Given the first program, it seems that the unchanging first element of
 the tuple could be handled by a Reader monad, leading to the second
 program, where b becomes the state, but how do I get the constant a from
 the Reader monad?

You need a monad-transformer to use both, Reader and State.
You can use either

ReaderT Double (State Double)

or

StateT Double (Reader Double)

(they're isomorphic).

Then you can query the modifiable state with get (from the MonadState 
class) and the immutable with ask (from the MonadReader class)

type Heron = StateT Double (Reader Double)

sqrtH :: Heron Double
sqrtH = do
  a - ask
  b - get
  let c = 0.5*(b + a/b)
  if (good enough)
    then return c
    else put c  sqrtH

mySqrt a = runReader (evalStateT sqrtH (a*0.5)) a




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


[Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread Steffen Schuldenzucker


Dear cafe,

does anyone have an explanation for this?:

 error (error foo)
*** Exception: foo

 error $ error foo
*** Exception: *** Exception: foo

-- Steffen

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


Re: [Haskell-cafe] Haskell Functions

2011-02-03 Thread Houdini

A project...this are my last questions,I'm not proeficient in haskell...this
explains why Im stuck... http://pastebin.com/GxQBh3hx
-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Haskell-Functions-tp3369769p3369938.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] Byte Histogram

2011-02-03 Thread Andrew Coppin
There now follows a small grab-bag of miscelaneous but related thoughts. 
(Which probably means that this post will spawn a 2000 message thread 
discussing one tiny side-issue, rather than the main thrust of the 
message...)




First of all, benchmarking. We have The Great Language Shootout, which 
tests how fast solutions implemented in various programming languages 
can be, given unbounded amounts of time, energy, expertise, and compiler 
modifications. Which is interesting, from a certain point of view.


In another sense, it's less interesting. For example, a C program can be 
as fast as any Haskell program, since compiling Haskell entails 
transforming it *into* C. (Unless you're seriously going to suggest that 
GHC's native code generator is any match for the might of a half-decent 
C compiler...)


That got me thinking about a more interesting question: Not *how fast* 
can it go, but *how easily* can it go fast? People have written fast C 
programs and fast Haskell programs, but how easy is it to write a 
typical program and have it go fast, without spending years optimising it?


With that in mind, I set of with a plan to do some small-scale 
benchmarking. Pick a problem, solve it in both Haskell and C++, in the 
simplest, most obvious way, and then apply the simplest, most obvious 
optimisations. Measure performance and compare.


There are benchmarks that just output some data. (Find all the prime 
numbers less than 1000...) I dislike these for a couple of reasons, not 
least because you can precompute the correct answer and just write a 
program which outputs that. (!) So I decided that all my benchmark 
programs should take a variable-sized data file as input, and save the 
results as output.


There's an old maxim of running benchmarks multiple times, to ensure 
that whatever time you got wasn't just a fluke. But then, maybe the 
first run pulls the input file into the file cache, and subsequent runs 
go faster. If your input data was randomly generated, perhaps you chose 
a particularly optimal or pessimal data set by accident. So I decided 
that each test run should use a different input file of approximately 
the same characteristics (size, random distribution, etc.)


So I ended up picking benchmarks like sort the lines of this file into 
ascending order, count the number of unique words in this file, 
produce a histogram of byte values, compute some statistics of this 
list of numbers, etc. The tasks are all extremely simple, so that there 
is some hope of it being possible to also implement them in C++.




One benchmark turned out to be particularly interesting: I call it byte 
histogram. The task is simple:

- Open a binary input file.
- Read a stream of bytes from it.
- Count how many times each of the 256 possible byte values appears.
The test inputs are binary files of various sizes, some with a uniform 
distribution, some with variously skewed distributions (so that some 
bytes have a vastly higher count than others).


Assuming we have some suitable import statements, it's quite easy to do 
this:


  bytes - BS.readFile Input.bin
  let out = BS.foldl' (\ map byte - MAP.insertWith (+) byte 1 map) 
MAP.empty bytes
  writeFile Output.csv (unlines $ map (\(k,v) - show k ++ , ++ 
show v) $ MAP.toAscList out)


(There is some slight trickiness if you want bytes with zero frequency 
to still be listed.)


All of this *works* perfectly - i.e., it produces the correct answers. 
It's also astronomically slow, and it's very easy to make it eat many 
gigabytes of RAM while it runs. (If the program starts actually 
swapping, then you will truly know what slow is!)


OK, so what happens if we replace Data.Map with Data.IntMap? Well, it 
goes slightly faster, and consumes slightly less RAM. Inputs which 
didn't quite complete before will run to completion now. But performance 
is still abysmal.


Enough with this tree sillyness. What happens if you use an array? Given 
that the entire program (apart from the last 0.02% of it) spends its 
time notionally mutating the data, a mutable array would be the logical 
choise. Dial up an IOArray Word8 Int and the structure of the program 
changes slightly, but it's still only a handful of lines of code. And 
the performance? Still glacial.


In particular, suppose we have

  inc :: IOArray Word8 Int - Word8 - IO ()
  inc array byte = do
count - readArray array byte
let count' = count + 1
writeArray array byte count'

in the main loop. The program is giving us the right answer, but using 
absurd amounts of time and space to get it. Now watch this:


  inc :: IOArray Word8 Int - Word8 - IO ()
  inc array byte = do
count - readArray array byte
let count' = count + 1
count' `seq` writeArray array byte count'

And now, suddenly, memory usage becomes constant, regardless of input 
size, and run-time is slashed. The program goes from taking 50 seconds 
to process a certain file to taking only 0.02 seconds. And from taking 
400 MB of RAM 

Re: [Haskell-cafe] Reader monad wrapping State monad

2011-02-03 Thread Daniel Fischer
On Thursday 03 February 2011 21:40:13, michael rice wrote:
 Hi Daniel,

 Ok, but what I was looking for was ReaderT on top, State on the bottom.

No problem, just change the definition of the Heron type synonym and swap 
the applcations of runReader[T] and evalState[T] in mySqrt, the monadic 
sqrtH can remain unchanged :)

 This is very confusing material, with no apparent conceptual commonality
 (ad hoc comes to mind) among the many examples I've looked at. Sometimes
 lift is used, other times a lift helper function, and in this case no
 use of lift at all.

That's because only methods of the MonadState and the MonadReader class are 
used and instances of MonadState are propagated/lifted through ReaderT, 
instance of MonadReader are propagated/lifted through StateT.

(
instance MonadReader r m = MonadReader r (StateT s m) where
ask = lift ask
local = ...
instance MonadState s m = MonadState (ReaderT r m) where
get = lift get
put = ...
)

If you use a function on the inner monad which is not propagated to the 
entire transformer stack via class instances, you have to use lift (if you 
have a MonadTrans instance) or something similar.


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


Re: [Haskell-cafe] Another Question

2011-02-03 Thread Richard O'Keefe

On 3/02/2011, at 8:18 PM, Navin Rustagi wrote:

 hi , 
 
 I am stuck in the following problem. 
 
 I am maintaining  a list of  tuples of the form 
 ([Char],Int,Int, Int,Int) . The purpose of maintaining the tuples is that the 
 program reads from a file line by line , Matches the contents with the first 
 element of the tuple and updates the tuple respectively.
 
 The precise function I am using is as follows 
 
 
 tupup::Bool-[Char]-Int-Int-Int-Int-Char-([Char],Int,Int,Int,Int) 
 tupup val elf els elr ell elx ys= if val then 
   case ys of  'A'  - (elf, 
 els+1,elr,ell,elx) 
   'G'  - (elf,els, elr 
 +1,ell,elx)
   'C'  - (elf,els,elr,  
 ell +1,elx) 
   'T'  - 
 (elf,els,elr,ell,  elx +1)
else (elf,els,elr,ell,elx)
 
 
 uptable::[[Char]]-[([Char],Int,Int,Int,Int)]-[([Char],Int,Int,Int,Int)]
 uptable (xf:xs) main_array = map (\(x,y,z,r,t)- tupup (x==xf) x y z r t 
 (secvalue xs) ) main_array

  
 It gives the error ERROR - Control stack overflow. I assume it is because of 
 the lazy evaluation .

The lazy evaluation of the ech+1 expressions, to be specific.

By the way, could I make a plea for narrower lines in your source code?
Ninety-nine columns is much wider than I find comfortable.

A little white space helps readability too.

I want to offer you a completely Haskell 98 solution.

Step 1.

Let's look at the types.  Trust me, this WILL pay off.  Twice.

The type (String,Int,Int,Int,Int) occurs several times here.
In fact this appears to represent a maplet String :- (Int,Int,Int,Int).
We'll refactor that and make a data type for the counts.

data Codon_Counts = Codon_Counts Int Int Int Int

type Codon_Map = [(String, Codon_Counts)]


Step 2.

   Two things are intermingled here: a control structure for applying a function
   to the second part of maplets whose first part equals a given key, and what
   to do to those second parts.  Let's factor out the control structure.

map_matching_maplets :: Eq k = k - (a - a) - [(k, a)] - [(k, a)]

map_matching_maplets k f = 
  map (\maplet@(key,val) - if key == k then (key,f val) else maplet)

Step 3.

Write an 'update_codon_map' function.

update_codon_map :: [String] - Codon_Map - Codon_Map

update_codon_map (what:how) =
map_matching_maplets what $
  case secvalue how of
'A' - \(Codon_Counts a g c t) - Codon_Counts (a+1) g c t
'G' - \(Codon_Counts a g c t) - Codon_Counts a (g+1) c t
'C' - \(Codon_Counts a g c t) - Codon_Counts a g (c+1) t
'T' - \(Codon_Counts a g c t) - Codon_Counts a g c (t+1)

Step 4.

Add strictness annotations.  In Haskell 98, the only place you
can put strictness annotations is in types.   That's one of the
reasons I introduced the Codon_Counts type.  Change just one line
so the declaration reads

data Codon_Counts
   = Codon_Counts !Int !Int !Int !Int

Step 5.

I suspect that there is still a big performance problem.
I *think* that this list of tuples is *really* a map from
some key to a set of codon counts, so that a call to
update_codon_map is expected to change just one maplet.

If that's so, then having a Codon_Map type has a big payoff, because
you can do

import qualified Data.Map as Map

type Codon_Map = Map.Map String Codon_Counts

update_codon_map (what:how) map = Map.update f what
  where f (Codon_Counts a g c t) =
  Just $ case secvalue how of
   'A' - Codon_Counts (a+1) g c t
   'G' - Codon_Counts a (g+1) c t
   'C' - Codon_Counts a g (c+1) t
   'T' - Codon_Counts a g c (t+1)

If there are n items in the map, the list based code is O(n),
while this is O(log n).



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


Re: [Haskell-cafe] Haskell Functions

2011-02-03 Thread Daniel Fischer
On Thursday 03 February 2011 21:37:45, Ozgur Akgun wrote:
 (CCing haskell-cafe again)

 Is this an homework question?

I think so: http://stackoverflow.com/questions/4877486/haskell-procedure
www.inf.ed.ac.uk/teaching/courses/inf2d/.../Inf2d-09-Assignment1.pdf

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


Re: [Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread Antoine Latter
On Thu, Feb 3, 2011 at 2:44 PM, Steffen Schuldenzucker
sschuldenzuc...@uni-bonn.de wrote:

 Dear cafe,

 does anyone have an explanation for this?:

 error (error foo)
 *** Exception: foo

 error $ error foo
 *** Exception: *** Exception: foo

I don't know if this is relevant, but I thought that the GHC compiler
believes that all exceptions are equivalent and indistinguishable -
that is, in the presence of multiple exceptional code-paths it will
make optimizations that would not otherwise otherwise be sound.

That might not be the issue here, but it is interesting.

http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm

Antoine



 -- Steffen

 ___
 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] ($) not as transparent as it seems

2011-02-03 Thread Daniel Peebles
This is indeed very strange. On my latest GHC 7 (built a couple of days ago)
it does the right thing when compiled, but in GHCi it behaves as you
describe. I have no idea, frankly.

On Thu, Feb 3, 2011 at 8:44 PM, Steffen Schuldenzucker 
sschuldenzuc...@uni-bonn.de wrote:


 Dear cafe,

 does anyone have an explanation for this?:

  error (error foo)
 *** Exception: foo

  error $ error foo
 *** Exception: *** Exception: foo

 -- Steffen

 ___
 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] Byte Histogram

2011-02-03 Thread Daniel Fischer
To illustrate your prediction about the side-issues:

On Thursday 03 February 2011 22:10:51, Andrew Coppin wrote:
 Consider for a moment the original implementation with Data.Map. Adding
 a seq or two here will do no good at all; seq reduces to WHNF. What we
 are wanting is NF, and I can see no way at all of doing that.

Check out Data.Map.insertWith'

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


Re: [Haskell-cafe] Reader monad wrapping State monad

2011-02-03 Thread michael rice
And swap the arguments.



Thanks for going the extra mile.



Michael


--- On Thu, 2/3/11, Daniel Fischer daniel.is.fisc...@googlemail.com wrote:

From: Daniel Fischer daniel.is.fisc...@googlemail.com
Subject: Re: [Haskell-cafe] Reader monad wrapping State monad
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Thursday, February 3, 2011, 4:15 PM

On Thursday 03 February 2011 21:40:13, michael rice wrote:
 Hi Daniel,

 Ok, but what I was looking for was ReaderT on top, State on the bottom.

No problem, just change the definition of the Heron type synonym and swap 
the applcations of runReader[T] and evalState[T] in mySqrt, the monadic 
sqrtH can remain unchanged :)

 This is very confusing material, with no apparent conceptual commonality
 (ad hoc comes to mind) among the many examples I've looked at. Sometimes
 lift is used, other times a lift helper function, and in this case no
 use of lift at all.

That's because only methods of the MonadState and the MonadReader class are 
used and instances of MonadState are propagated/lifted through ReaderT, 
instance of MonadReader are propagated/lifted through StateT.

(
instance MonadReader r m = MonadReader r (StateT s m) where
    ask = lift ask
    local = ...
instance MonadState s m = MonadState (ReaderT r m) where
    get = lift get
    put = ...
)

If you use a function on the inner monad which is not propagated to the 
entire transformer stack via class instances, you have to use lift (if you 
have a MonadTrans instance) or something similar.




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


Re: [Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread Tim Chevalier
On Thu, Feb 3, 2011 at 12:44 PM, Steffen Schuldenzucker
sschuldenzuc...@uni-bonn.de wrote:

 Dear cafe,

 does anyone have an explanation for this?:

 error (error foo)
 *** Exception: foo

 error $ error foo
 *** Exception: *** Exception: foo


Have you read the intermediate Core (using -ddump-simpl) for each variation?

Cheers,
Tim


-- 
Tim Chevalier * http://cs.pdx.edu/~tjc/ * Often in error, never in doubt
an intelligent person fights for lost causes,realizing that others
are merely effects -- E.E. Cummings

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


Re: [Haskell-cafe] hsmagick on OSX 10.6

2011-02-03 Thread Tim Chevalier
On Thu, Feb 3, 2011 at 10:43 AM, Max Cantor mxcan...@gmail.com wrote:
 Just out of curiosity, has anyone gotten this to work?  I'm getting bus 
 errors whenever I call readImage.

 If anyone out there has gotten it working and would tell me which versions 
 they're using of the relevant bits, that would be very much appreciated.  
 Also, I'll post all my debug info if there's someone who's gotten this to 
 work.


Hi Max --

I know that several people have used hsmagick successfully, but I
don't have Mac OS 10.6 (I use 10.5.8), so I can't try to reproduce
your problem.

Vincent Gerard is taking over maintainership of the library, so you
may want to cc him on any emails. In general it's not too safe to
assume that any particular library maintainer reads haskell-cafe
regularly :-)

Cheers,
Tim (hsmagick maintainer)


-- 
Tim Chevalier * http://cs.pdx.edu/~tjc/ * Often in error, never in doubt
an intelligent person fights for lost causes,realizing that others
are merely effects -- E.E. Cummings

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


Re: [Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread Don Stewart
catamorphism:
 On Thu, Feb 3, 2011 at 12:44 PM, Steffen Schuldenzucker
 sschuldenzuc...@uni-bonn.de wrote:
 
  Dear cafe,
 
  does anyone have an explanation for this?:
 
  error (error foo)
  *** Exception: foo
 
  error $ error foo
  *** Exception: *** Exception: foo
 
 
 Have you read the intermediate Core (using -ddump-simpl) for each variation?
 

A.
GHC.Base.bindIO
  @ GHC.Prim.Any
  @ [()]
  ((GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# foo))
   `cast` (CoUnsafe [GHC.Types.Char] (GHC.Types.IO GHC.Prim.Any)
   :: [GHC.Types.Char] ~ GHC.Types.IO GHC.Prim.Any))
  ((\ (it_ade :: GHC.Prim.Any)
  (eta_B1 :: GHC.Prim.State# GHC.Prim.RealWorld) -
  ((GHC.Base.returnIO
  @ [()]
  (GHC.Types.:
 @ ()
 (it_ade `cast` (CoUnsafe GHC.Prim.Any () :: GHC.Prim.Any ~ ()))
 (GHC.Types.[] @ (
   `cast` (GHC.Types.NTCo:IO [()]
   :: GHC.Types.IO [()]
~
  (GHC.Prim.State# GHC.Prim.RealWorld
   - (# GHC.Prim.State# GHC.Prim.RealWorld, [()] #
eta_B1)
   `cast` (GHC.Prim.Any - sym (GHC.Types.NTCo:IO [()])
   :: (GHC.Prim.Any
   - GHC.Prim.State# GHC.Prim.RealWorld
   - (# GHC.Prim.State# GHC.Prim.RealWorld, [()] #))
~
  (GHC.Prim.Any - GHC.Types.IO [()])))

B.
GHC.Base.bindIO
  @ GHC.Prim.Any
  @ [()]
  (GHC.Base.$
 @ [GHC.Types.Char]
 @ (GHC.Types.IO GHC.Prim.Any)
 (GHC.Err.error @ (GHC.Types.IO GHC.Prim.Any))
 (GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# foo)))
  ((\ (it_aib :: GHC.Prim.Any)
  (eta_B1 :: GHC.Prim.State# GHC.Prim.RealWorld) -
  ((GHC.Base.returnIO
  @ [()]
  (GHC.Types.:
 @ ()
 (it_aib `cast` (CoUnsafe GHC.Prim.Any () :: GHC.Prim.Any ~ ()))
 (GHC.Types.[] @ (
   `cast` (GHC.Types.NTCo:IO [()]
   :: GHC.Types.IO [()]
~
  (GHC.Prim.State# GHC.Prim.RealWorld
   - (# GHC.Prim.State# GHC.Prim.RealWorld, [()] #
eta_B1)
   `cast` (GHC.Prim.Any - sym (GHC.Types.NTCo:IO [()])
   :: (GHC.Prim.Any
   - GHC.Prim.State# GHC.Prim.RealWorld
   - (# GHC.Prim.State# GHC.Prim.RealWorld, [()] #))
~
  (GHC.Prim.Any - GHC.Types.IO [()])))


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


Re: [Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread Luke Palmer
This is probably a result of strictness analysis.  error is
technically strict, so it is reasonable to optimize to:

let e = error foo in e `seq` error e

On Thu, Feb 3, 2011 at 1:44 PM, Steffen Schuldenzucker
sschuldenzuc...@uni-bonn.de wrote:

 Dear cafe,

 does anyone have an explanation for this?:

 error (error foo)
 *** Exception: foo

 error $ error foo
 *** Exception: *** Exception: foo

 -- Steffen

 ___
 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] Byte Histogram

2011-02-03 Thread Andrew Coppin

On 03/02/2011 09:37 PM, Daniel Fischer wrote:

To illustrate your prediction about the side-issues:

On Thursday 03 February 2011 22:10:51, Andrew Coppin wrote:

Consider for a moment the original implementation with Data.Map. Adding
a seq or two here will do no good at all; seq reduces to WHNF. What we
are wanting is NF, and I can see no way at all of doing that.


Check out Data.Map.insertWith'


*facepalm*

Wouldn't that still mean that the spine of the map is still lazy though?

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


Re: [Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread Tim Chevalier
On Thu, Feb 3, 2011 at 2:03 PM, Luke Palmer lrpal...@gmail.com wrote:
 This is probably a result of strictness analysis.  error is
 technically strict, so it is reasonable to optimize to:

    let e = error foo in e `seq` error e


Yes, and you can see this in the Core code that Don posted: in version
(A), GHC optimized away the outer call to error. But in version (B),
the demand analyzer only knows that ($) is strict in its first
argument -- it's not strict in its second. So it's not obviously safe
to do the same optimization: the demand analyzer doesn't look
through higher-order function arguments IIRC. (You can confirm this
for yourself if you also want to read the demand analyzer output.)

If ($) were getting inlined, the code would look the same coming into
demand analysis in both cases, so you wouldn't see a difference. So
I'm guessing you're compiling with -O0.

Cheers,
Tim

-- 
Tim Chevalier * http://cs.pdx.edu/~tjc/ * Often in error, never in doubt
an intelligent person fights for lost causes,realizing that others
are merely effects -- E.E. Cummings

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


Re: [Haskell-cafe] Byte Histogram

2011-02-03 Thread Johan Tibell
Hi,

Thanks for bringing up these issues. It's something we could be better
at addressing as a community.

First, we need to stop pretending that you can use Haskell effectively
without first learning to reason about program evaluation order.
Learning how is not terrible difficult, but there's very little
material on how to do it [1]. Some of us have learnt it the hard way
by experimentation or by talking to people who do understand lazy
evaluation [2] (the Simons, Don, and Bryan to name a few). At the very
least we need to teach people how to tell which arguments a pure
function is strict in by looking at its definition.

Second, many of our core data structures are lazy, but most uses are
strict. That keeping a simple map of counters is tricky should tell us
that something is wrong (you need to use insertWith'). It wouldn't be
if Data.Map was strict in the values. Many strictness related problems
people have are due to common data types like Maybe, tuples, and
arrays being lazy. This is rarely what you want.

1. I tried to start creating some. For example, by giving a high
performance Haskell talk at CUFP. Unfortunately the talk wasn't taped.
2. Haskell is non-strict, which doesn't necessarily imply lazy
evaluation. However, lazy evaluation is what we actually deal with.

Johan

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


Re: [Haskell-cafe] Byte Histogram

2011-02-03 Thread Johan Tibell
On Thu, Feb 3, 2011 at 11:10 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
 Wouldn't that still mean that the spine of the map is still lazy though?

No, Data.Map and Data.Set are both spine strict (which should be
documented!). Data.Map is key strict in addition. Both are value lazy.

Johan

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


Re: [Haskell-cafe] Byte Histogram

2011-02-03 Thread Johan Tibell
Hi,

For what it's worth I saw the problems in your counting examples right
away, without reading the explanatory text below. Hopefully that means
that it's possibly to learn how to spot such things without resorting
to e.g. running the program or reading Core *gasp*.

Johan

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


Re: [Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread Daniel Fischer
On Thursday 03 February 2011 23:03:36, Luke Palmer wrote:
 This is probably a result of strictness analysis.  error is
 technically strict, so it is reasonable to optimize to:

 let e = error foo in e `seq` error e


I think so too.
Unoptimised, 

module Errors where

foo = error (error foo)

bar = error $ error bar

produces the core

Errors.bar :: forall a_aaN. a_aaN
[GblId]
Errors.bar =
  \ (@ a_aaN) -
GHC.Base.$
  @ [GHC.Types.Char]
  @ a_aaN
  (GHC.Err.error @ a_aaN)
  (GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# bar))

a_rb8 :: [GHC.Types.Char]
[GblId, Str=DmdType b]
a_rb8 =
  GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# foo)

Errors.foo :: forall a_aaP. a_aaP
[GblId]
Errors.foo =
  (\ (@ a_aaP) - a_rb8)
  `cast` (forall a_aaP. CoUnsafe [GHC.Types.Char] a_aaP
  :: (forall a_aaP. [GHC.Types.Char]) ~ (forall a_aaP. a_aaP))
==

The first argument to ($) is evaluated before the second [because the 
function may be lazy), resulting in the start of the error message 
***Exception: , then that error-call must evaluate its argument, error 
bar, which results in ***Exception: bar (and terminates the thread) and 
two ***Exception:  being printed. If I interpret the core correctly, 
error is so well known to the compiler that it strips off the outer `error' 
in foo even without optimisations (which surprises me a bit).

With optimisations, ($) is inlined and `error $ error bar' is transformed 
to error (error bar), from then on both have identical structure and 
arrive at (mutatis mutandis) the same core (which is nearly the same as foo 
got without optimisations).

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


Re: [Haskell-cafe] Byte Histogram

2011-02-03 Thread Daniel Fischer
On Thursday 03 February 2011 23:19:31, Johan Tibell wrote:
 Hi,

 For what it's worth I saw the problems in your counting examples right
 away, without reading the explanatory text below.

Yes, they were pretty obvious with enough experience. For beginners I 
expect it to be a rather insidious trap.

 Hopefully that means
 that it's possibly to learn how to spot such things without resorting
 to e.g. running the program or reading Core *gasp*.

Within limits. Detrimental laziness or strictness can be arbitrarily well 
hidden.


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


Re: [Haskell-cafe] Byte Histogram

2011-02-03 Thread Richard O'Keefe

On 4/02/2011, at 10:10 AM, Andrew Coppin wrote:
 
 The important obsevation is this: One tiny, almost insignificant change can 
 transform a program from taking 50 seconds and 400 MB of RAM into one that 
 takes 0.02 seconds and 0.1 MB of RAM. And, at least in this case, the simpler 
 version is the slow one.
 
 To say that Haskell is slow is both a little bit vague, and not really 
 backed up by facts. In about 5 minutes flat, I managed to write a Haskell 
 program that's very simple, and yet faster than a comparably simple C++ 
 program (and C++ is supposed to be fast). So it's not that Haskell is 
 slow. It's that Haskell is *tricky*. Tiny, tiny little changes that look 
 innocuous can have vast effects on performance. And this is a nice little 
 example of that effect.

This seems to me to be the heart of the message, so maybe this reply is 
on-topic.

Back in the days when systems other than Wintel and maybe sort of intel Linux 
were
supported by Clean, I used to really love one of the features of the Clean 
compiler.
One simple command line switch and the compiler would list the names of all your
top level functions together with their types, and the types included 
strictness.
(Also uniqueness, not relevant to Haskell.)

The GHC documentation says the information is in the interface files,
but they are binary now, and I can't find it there.

 That got me thinking... What would happen if, instead of Integer, we had 
 two types, evaluated Integer and possibly unevaluated Integer? What if 
 the strictness or otherwise of a data structure were exposed at the type 
 level?

Oh, you mean like !Int and Int in Clean?  I used to find bang *types* 
rather easier to deal with
than I now do bang *patterns*.

 Currently, if you want a strict list, you have to implement one yourself. But 
 is that strict in the spine, or the elements, or what?

Spine strict: ![t].
Spine and element strict: ![!t].
 
 I have no idea what the syntax for that would look like,

Clean?



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


Re: [Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread Dan Doel
On Thursday 03 February 2011 5:12:54 PM Tim Chevalier wrote:
 On Thu, Feb 3, 2011 at 2:03 PM, Luke Palmer lrpal...@gmail.com wrote:
  This is probably a result of strictness analysis.  error is
  technically strict, so it is reasonable to optimize to:
  
 let e = error foo in e `seq` error e
 
 Yes, and you can see this in the Core code that Don posted: in version
 (A), GHC optimized away the outer call to error. But in version (B),
 the demand analyzer only knows that ($) is strict in its first
 argument -- it's not strict in its second. So it's not obviously safe
 to do the same optimization: the demand analyzer doesn't look
 through higher-order function arguments IIRC. (You can confirm this
 for yourself if you also want to read the demand analyzer output.)
 
 If ($) were getting inlined, the code would look the same coming into
 demand analysis in both cases, so you wouldn't see a difference. So
 I'm guessing you're compiling with -O0.

Whatever is going on, it has to be active during ghci, because all these 
differences can be seen during interpretation (in 7.0.1, at least).

  Prelude error (error foo)
  *** Exception: foo
  Prelude error $ error foo
  *** Exception: *** Exception: foo
  Prelude let g :: (a - b) - a - b ; g f x = f x in g error (error foo)
  *** Exception: foo
  Prelude let g :: (a - b) - a - b ; g f x = f x
  Prelude g error (error foo)
  *** Exception: *** Exception: foo
  Prelude let foo = error foo in error foo
  *** Exception: foo
  Prelude let foo = error foo
  Prelude error foo
  *** Exception: *** Exception: foo

Actually compiling seems to remove the difference in 7.0.1, at least, because 
the output is always:

  Foo: foo

regardless of ($) or not ('fix error' hangs without output as well, which 
isn't what I thought would happen).

Anyhow, that rules out most general-purpose optimizations (including 
strictness analysis, I thought).

- Dan

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


Re: [Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread John Meacham
In general, errors are always interchangeable with another. An
exception in haskell is a value, rather than an event. Haskell
prescribes no evaluation order other than if the result is defined it
must be equivalant to the one generated by a normal-order reduction
strategy. Since error is not a valid value, any behavior including
just locking up is a completely acceptable (if not very friendly)
thing for a compiler to do.

In practice, we like writing compilers that help us find our errors
and using compilers that don't obfuscate them so compilers tend to
behave more or less like youd expect when presented with error, but
not at the expense of optimization or other necessary transformations.

 GHC has stronger guarentees in order to support its imprecise
exceptions extension in that the exceptional value returned is
guarenteed to be (non-deterministically) selected from the set of all
possible errors for every possible evaluation order of the expression.
So It won't just conjure up something new out of thin air, but neither
can you expect any particular exception when your code can produce
more than one.

John

On Thu, Feb 3, 2011 at 2:42 PM, Dan Doel dan.d...@gmail.com wrote:
 On Thursday 03 February 2011 5:12:54 PM Tim Chevalier wrote:
 On Thu, Feb 3, 2011 at 2:03 PM, Luke Palmer lrpal...@gmail.com wrote:
  This is probably a result of strictness analysis.  error is
  technically strict, so it is reasonable to optimize to:
 
     let e = error foo in e `seq` error e

 Yes, and you can see this in the Core code that Don posted: in version
 (A), GHC optimized away the outer call to error. But in version (B),
 the demand analyzer only knows that ($) is strict in its first
 argument -- it's not strict in its second. So it's not obviously safe
 to do the same optimization: the demand analyzer doesn't look
 through higher-order function arguments IIRC. (You can confirm this
 for yourself if you also want to read the demand analyzer output.)

 If ($) were getting inlined, the code would look the same coming into
 demand analysis in both cases, so you wouldn't see a difference. So
 I'm guessing you're compiling with -O0.

 Whatever is going on, it has to be active during ghci, because all these
 differences can be seen during interpretation (in 7.0.1, at least).

  Prelude error (error foo)
  *** Exception: foo
  Prelude error $ error foo
  *** Exception: *** Exception: foo
  Prelude let g :: (a - b) - a - b ; g f x = f x in g error (error foo)
  *** Exception: foo
  Prelude let g :: (a - b) - a - b ; g f x = f x
  Prelude g error (error foo)
  *** Exception: *** Exception: foo
  Prelude let foo = error foo in error foo
  *** Exception: foo
  Prelude let foo = error foo
  Prelude error foo
  *** Exception: *** Exception: foo

 Actually compiling seems to remove the difference in 7.0.1, at least, because
 the output is always:

  Foo: foo

 regardless of ($) or not ('fix error' hangs without output as well, which
 isn't what I thought would happen).

 Anyhow, that rules out most general-purpose optimizations (including
 strictness analysis, I thought).

 - Dan

 ___
 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] ($) not as transparent as it seems

2011-02-03 Thread Steffen Schuldenzucker


Thanks to all of you for making GHC's behaviour yet a bit clearer to me.

On 02/03/2011 11:25 PM, Daniel Fischer wrote:

On Thursday 03 February 2011 23:03:36, Luke Palmer wrote:
   

This is probably a result of strictness analysis.  error is
technically strict, so it is reasonable to optimize to:

 let e = error foo in e `seq` error e

 

I think so too.
Unoptimised,

module Errors where

foo = error (error foo)

bar = error $ error bar

produces the core

Errors.bar :: forall a_aaN. a_aaN
[GblId]
Errors.bar =
   \ (@ a_aaN) -
 GHC.Base.$
   @ [GHC.Types.Char]
   @ a_aaN
   (GHC.Err.error @ a_aaN)
   (GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# bar))

a_rb8 :: [GHC.Types.Char]
[GblId, Str=DmdType b]
a_rb8 =
   GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# foo)

Errors.foo :: forall a_aaP. a_aaP
[GblId]
Errors.foo =
   (\ (@ a_aaP) -  a_rb8)
   `cast` (forall a_aaP. CoUnsafe [GHC.Types.Char] a_aaP
   :: (forall a_aaP. [GHC.Types.Char]) ~ (forall a_aaP. a_aaP))
==

The first argument to ($) is evaluated before the second [because the
function may be lazy), resulting in the start of the error message
***Exception: , then that error-call must evaluate its argument, error
bar, which results in ***Exception: bar (and terminates the thread) and
two ***Exception:  being printed. If I interpret the core correctly,
error is so well known to the compiler that it strips off the outer `error'
in foo even without optimisations (which surprises me a bit).

With optimisations, ($) is inlined and `error $ error bar' is transformed
to error (error bar), from then on both have identical structure and
arrive at (mutatis mutandis) the same core (which is nearly the same as foo
got without optimisations).
   



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


Re: [Haskell-cafe] Byte Histogram

2011-02-03 Thread Erik de Castro Lopo
Daniel Fischer wrote:

 On Thursday 03 February 2011 23:19:31, Johan Tibell wrote:
  Hi,
 
  For what it's worth I saw the problems in your counting examples right
  away, without reading the explanatory text below.
 
 Yes, they were pretty obvious with enough experience. For beginners I 
 expect it to be a rather insidious trap.
 
  Hopefully that means
  that it's possibly to learn how to spot such things without resorting
  to e.g. running the program or reading Core *gasp*.
 
 Within limits. Detrimental laziness or strictness can be arbitrarily well 
 hidden.

I am a relative newcomer to Haskell, but I think I have a reasonable
understanding of the executaion model. Enough to fix performance
issues in simple code like the example given.

However, one of the Haskell projects I work on is Ben Lippmeier's
DDC compiler. Thats about 5 lines of Haskell code and finding
performance issues there is really difficult. 

Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/

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


Re: [Haskell-cafe] Problems with iteratees

2011-02-03 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2/2/11 20:06 , wren ng thornton wrote:
 When I put this all together, the process is killed with:
 control message: Just (Err endOfInput)

POSIX FIFOs and GHC's nonblocking file descriptors implementation don't play
well together; you should launch the writer end first and let it block
waiting for the reader, or you should switch to opening the FIFO r/w and add
a control message for end-of-stream (the usual way to work with FIFOs).

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]allber...@gmail.com
system administrator  [openafs,heimdal,too many hats]kf8nh
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1LRWYACgkQIn7hlCsL25UhiwCePaEpZM0wlKRabmOT0SV7UKbP
Bc8AnRs+QTl59Cn9JRWUfNE1MBGv0X1S
=Fvqe
-END PGP SIGNATURE-

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


[Haskell-cafe] Haskell AES

2011-02-03 Thread tsuraan
I'd like to use AES in a haskell program that I'm writing.  I've come
across three libraries in hackage that do AES: the library named AES,
the Crypto library, and the SimpleAES library.  The library named AES
says in its documentation for the crypt function that it is not
thread-safe.  What exactly does this mean in haskell?  Does it mean
that if you have separate AESCtx instances in different forkIO
threads, that things will break?  Or does it just mean that using
the same AESCtx in multiple forkIO threads is a bad idea?

I'm asking about that one comment because it looks like SimpleAES is
probably a wrapper around AES, and the Crypto library also says it
uses a library named AES, although one by an author not listed in the
hackage AES library entry.

Can anybody shed some light on the state of AES encryption in haskell?
What is the preferred library, especially for us in a program that has
many forkIO'd threads?

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


Re: [Haskell-cafe] Problems with iteratees

2011-02-03 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2/3/11 19:16 , Brandon S Allbery KF8NH wrote:
 POSIX FIFOs and GHC's nonblocking file descriptors implementation don't play
 well together; you should launch the writer end first and let it block

More specifically, I think what's happening here is that a non-blocking
open() of a FIFO returns with the fd not actually open yet, a situation
which isn't expected, and a blocking open will block until the other side is
opened.

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]allber...@gmail.com
system administrator  [openafs,heimdal,too many hats]kf8nh
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1LRf4ACgkQIn7hlCsL25V8dQCgjD+pLVt9LbyqRJ8VYeF8XuLt
ieQAoJl/3ws1hh8OJtrjVTyPx9gDRGgW
=EcXI
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] Problems with iteratees

2011-02-03 Thread wren ng thornton

On 2/3/11 8:05 AM, John Lato wrote:

I don't have too much to add to Maciej and Oleg's reply, except that I'd
recommend looking at the Wave codec over the Tiff reader in those versions
of iteratee.  I don't think that's the only problem, though, because then
you'd be getting a Divergent iteratee error.


I'll try taking a look at them. I hadn't because I know nothing about 
Tiff and Wave formats, so I wouldn't know what I'm looking at regarding 
the gritty details of iteratee semantics. The error handling stuff is by 
far the murkiest part of the various iteratee designs IMO.




The endOfInput error is suspicious, and I think you'll need to track it
down to solve this problem.  It doesn't appear to be from either iteratee or
protocol-buffers.  Could it be coming from your IO library?  I wonder if the
enumerator is trying to force a read after EOF has been reached for some
reason?


That's definitely the suspicious bit. It's not coming from any of my 
code (including the hprotoc-generated code), and I didn't see anything 
in iteratee nor protocol-buffers that could throw it either...


I just got fed up with it and ran `strings` on all the libraries I link 
against, and the only one that turns up with endOfInput is attoparsec 
(which has a function by that name). But I'm not using attoparsec 
anywhere near this segment of code... Well, it's a lead at least.




As an experiment, you could try using a custom convStream function like
this:

convStream2
:: Monad m
= IterateeG s el m (Maybe (s' el'))
- EnumeratorN s el s' el' m a
convStream2 fi iter = fi = check
where
check (Just xs) = lift (runIter iter $ Chunk xs) = docase
check (Nothing) = return iter
docase (Done a _)   = return $ return a
docase (Cont k Nothing) = convStream2 fi k
docase (Cont k (Just endOfInput)) = convStream2 (return Nothing) k
docase (Cont _ (Just e))= return $ throwErr e

This may help determine if it's a problem with IO or with the message
parsing.


Thanks, that's a good idea.

--
Live well,
~wren

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


Re: [Haskell-cafe] OSX i386/x86 and x86_64 - time to switch supported platforms?

2011-02-03 Thread wren ng thornton

On 2/3/11 10:48 AM, Max Cantor wrote:

Does it make sense to relegate OSX x86_64 to community status
while the 32-bit version is considered a supported platform?


I'm not sure I can make sense of what you mean here. Given the preamble, 
I'd guess you're asking whether we should make x86_64 the targeted 
architecture for OSX support, and reclassify 32-bit OSX to unsupported 
or hopefully it still works status. (But in that case, it's the 32-bit 
which would be relegated to unsupported status while x86_64 is 
considered a supported platform...)


Can you clarify the question?

--
Live well,
~wren

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


Re: [Haskell-cafe] Problems with iteratees

2011-02-03 Thread wren ng thornton

On 2/3/11 7:19 PM, Brandon S Allbery KF8NH wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2/3/11 19:16 , Brandon S Allbery KF8NH wrote:

POSIX FIFOs and GHC's nonblocking file descriptors implementation don't play
well together; you should launch the writer end first and let it block


More specifically, I think what's happening here is that a non-blocking
open() of a FIFO returns with the fd not actually open yet, a situation
which isn't expected, and a blocking open will block until the other side is
opened.


When opening the Fd[1], the program does block until the other end is 
opened by another process (verified via printf debugging). But I'll keep 
that in mind while digging around. I was aware of semi-closed handles, 
but not semi-open Fds.



[1] Via (System.Posix.IO.openFd file System.Posix.IO.ReadOnly Nothing 
System.Posix.IO.defaultFileFlags). Unfortunately, if compiled under GHC 
= 6.12.1 with -threaded, then openFd will always throw an error about 
the system call being interrupted by GHC's thread scheduling timer. This 
bug is fixed in unix-2.4.1.0 which, IIRC, requires GHC-7. The problem is 
that the earlier implementation of openFd uses throwErrnoPathIfMinus1, 
instead of throwErrnoPathIfMinus1Retry (which does not exist in base = 
4.3.0.0). Cf.,


http://www.haskell.org/pipermail/glasgow-haskell-users/2009-December/018147.html

--
Live well,
~wren

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


Re: [Haskell-cafe] OSX i386/x86 and x86_64 - time to switch supported platforms?

2011-02-03 Thread Richard O'Keefe

On 4/02/2011, at 2:14 PM, wren ng thornton wrote:

 On 2/3/11 10:48 AM, Max Cantor wrote:
 Does it make sense to relegate OSX x86_64 to community status
 while the 32-bit version is considered a supported platform?
 
 I'm not sure I can make sense of what you mean here. Given the preamble, I'd 
 guess you're asking whether we should make x86_64 the targeted architecture 
 for OSX support, and reclassify 32-bit OSX to unsupported or hopefully it 
 still works status. (But in that case, it's the 32-bit which would be 
 relegated to unsupported status while x86_64 is considered a supported 
 platform...)
 
 Can you clarify the question?

Here's something that happened to me:  GHC was installed on this machine and 
worked fine,
but when the operating system was upgraded to Mac OS X 10.6.something, GHC 
broke, with
messages along the lines of you can't use 32-bit absolute addresses in 64-bit 
code.
The operating system is perfectly happy running both 32-bit and 64-code code 
and all
the tool chain is happy working with either, but the *default* changed from 
say nothing
get 32-bit to say nothing get 64-bit.  I'm guessing that GHC gives the 
compiler some
C code and some (32-bit) object files or libraries.

So now I have *different* GHC setups on the 10.6.5 desktop machine and the
10.5.8 laptop...  Since both machines have only 4GB of physical memory, 32-bit 
would be
fine, except for all those lovely extra registers in x86_64 mode.

I think the original poster is saying that the targeted architecture for OS X 
support
should be the architecture that OS X assumes by default, and these days that's 
x86_64.

It would be really nice for x86 mode to be well supported for a while longer.


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


Re: [Haskell-cafe] OSX i386/x86 and x86_64 - time to switch supported platforms?

2011-02-03 Thread Max Cantor
 I'm not sure I can make sense of what you mean here. Given the preamble, I'd 
 guess you're asking whether we should make x86_64 the targeted architecture 
 for OSX support, and reclassify 32-bit OSX to unsupported or hopefully it 
 still works status. (But in that case, it's the 32-bit which would be 
 relegated to unsupported status while x86_64 is considered a supported 
 platform...)

Yes.  I'm saying that I believe that OSX x86_64 should be the officially 
supported platform instead of 32-bit x86 with all the associated guarantees and 
assurances.   I wanted to see how people felt about that.

mc

 
 Can you clarify the question?
 
 Here's something that happened to me:  GHC was installed on this machine and 
 worked fine,
 but when the operating system was upgraded to Mac OS X 10.6.something, GHC 
 broke, with
 messages along the lines of you can't use 32-bit absolute addresses in 
 64-bit code.
 The operating system is perfectly happy running both 32-bit and 64-code code 
 and all
 the tool chain is happy working with either, but the *default* changed from 
 say nothing
 get 32-bit to say nothing get 64-bit.  I'm guessing that GHC gives the 
 compiler some
 C code and some (32-bit) object files or libraries.
 
 So now I have *different* GHC setups on the 10.6.5 desktop machine and the
 10.5.8 laptop...  Since both machines have only 4GB of physical memory, 
 32-bit would be
 fine, except for all those lovely extra registers in x86_64 mode.
 
 I think the original poster is saying that the targeted architecture for OS X 
 support
 should be the architecture that OS X assumes by default, and these days 
 that's x86_64.
 
 It would be really nice for x86 mode to be well supported for a while longer.
 
 
 ___
 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] OSX i386/x86 and x86_64 - time to switch supported platforms?

2011-02-03 Thread wren ng thornton

Max Cantor wrote:

someone? wrote:

I think the original poster is saying that the targeted architecture for OS X 
support
should be the architecture that OS X assumes by default, and these days that's 
x86_64.


That sounds reasonable to me. The big caveat is that OSX = 10.5.8   
10.6 should still be targeted as well. While non-x86_64 Macs are quite 
old, OSX 10.6 is still pretty new and so there are a lot of people still 
using 10.5 (and our department still has a couple boxes running 10.4).


So even though 10.5.8 defaults to 32-bit, it should still be actively 
supported (as an x86_64 architecture). Just pass the necessary flags to 
gcc :)




It would be really nice for x86 mode to be well supported for a while longer.


Yes, it'd be really nice to support 32-bit mode for a while yet, even if 
it isn't actively being targeted for improvements.


--
Live well,
~wren

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


Re: [Haskell-cafe] OSX i386/x86 and x86_64 - time to switch supported platforms?

2011-02-03 Thread Max Cantor
Doesn't 10.5.x have the ability to generate and run 64-bit binaries?

mc

On Feb 4, 2011, at 10:19 AM, wren ng thornton wrote:

 Max Cantor wrote:
 someone? wrote:
 I think the original poster is saying that the targeted architecture for OS 
 X support
 should be the architecture that OS X assumes by default, and these days 
 that's x86_64.
 
 That sounds reasonable to me. The big caveat is that OSX = 10.5.8   10.6 
 should still be targeted as well. While non-x86_64 Macs are quite old, OSX 
 10.6 is still pretty new and so there are a lot of people still using 10.5 
 (and our department still has a couple boxes running 10.4).
 
 So even though 10.5.8 defaults to 32-bit, it should still be actively 
 supported (as an x86_64 architecture). Just pass the necessary flags to gcc :)
 
 
 It would be really nice for x86 mode to be well supported for a while 
 longer.
 
 Yes, it'd be really nice to support 32-bit mode for a while yet, even if it 
 isn't actively being targeted for improvements.
 
 -- 
 Live well,
 ~wren
 
 ___
 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] OSX i386/x86 and x86_64 - time to switch supported platforms?

2011-02-03 Thread Steve Severance
Wholly support moving OSX to x64. x86 should be supported only on a
best effort basis for legacy.

Steve

On Thu, Feb 3, 2011 at 6:28 PM, Max Cantor mxcan...@gmail.com wrote:
 Doesn't 10.5.x have the ability to generate and run 64-bit binaries?

 mc

 On Feb 4, 2011, at 10:19 AM, wren ng thornton wrote:

 Max Cantor wrote:
 someone? wrote:
 I think the original poster is saying that the targeted architecture for 
 OS X support
 should be the architecture that OS X assumes by default, and these days 
 that's x86_64.

 That sounds reasonable to me. The big caveat is that OSX = 10.5.8   10.6 
 should still be targeted as well. While non-x86_64 Macs are quite old, OSX 
 10.6 is still pretty new and so there are a lot of people still using 10.5 
 (and our department still has a couple boxes running 10.4).

 So even though 10.5.8 defaults to 32-bit, it should still be actively 
 supported (as an x86_64 architecture). Just pass the necessary flags to gcc 
 :)


 It would be really nice for x86 mode to be well supported for a while 
 longer.

 Yes, it'd be really nice to support 32-bit mode for a while yet, even if it 
 isn't actively being targeted for improvements.

 --
 Live well,
 ~wren

 ___
 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




-- 

Steve Severance
c. 240.472.9645
e. st...@medwizard.net


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


Re: [Haskell-cafe] OSX i386/x86 and x86_64 - time to switch supported platforms?

2011-02-03 Thread wren ng thornton

On 2/3/11 9:28 PM, Max Cantor wrote:

Doesn't 10.5.x have the ability to generate and run 64-bit binaries?


Yes, it does. But it defaults to 32-bit as I recall. Richard O'Keefe 
suggested a general practice of targeting the architecture considered 
default by the operating system. That's a good suggestion; I was just 
pointing out that when new versions of OSX change the default 
architecture, we should continue to support older versions of OSX on the 
newly-default architecture even though that architecture isn't the 
default one for the older version of OSX.


--
Live well,
~wren

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


Re: [Haskell-cafe] How to #include into .lhs files?

2011-02-03 Thread Conal Elliott
Thanks, Daniel. I'm still stumped. When I say

#include B.hs

in a .hs file, all works fine, but when in a .lhs file I get error: B.hs:
No such file or directory. The file B.hs is in the same directory as the
including file, which is the current directory for ghci. Same situation with
ghc.

If I change B.hs to ./B.hs, I get the same behavior. Only if I use a
fully qualified path name for B.hs does it get found from the .lhs file.

I'm using GHC 6.12.3 on Mac OS 10.6.6.

Any ideas? (Anyone, not just Daniel.)

Thanks,  - Conal


On Thu, Feb 3, 2011 at 2:51 AM, Daniel Fischer 
daniel.is.fisc...@googlemail.com wrote:

 On Thursday 03 February 2011 10:33:23, Conal Elliott wrote:
  Does anyone have a working example of #include'ing Haskell code into a
  bird-tracks-style .lhs file with GHC? Every way I try leads to parsing
  errors. Is there documentation about how it's supposed to work?
 
  Help much appreciated.   - Conal

 Stupid example:

 -- Main:

  {-# LANGUAGE CPP #-}
  module Main (main) where

 #include MachDeps.h

  main :: IO ()
  main = do

 #if WORD_SIZE_IN_BITS == 32

  putStrLn 32 bits

 #include Stuff32

 # else

  putStrLn 64 bits

 #include Stuff64
 #endif

 -- Stuff32:

  putStrLn Included from Stuff32

 -- Stuff64:

  putStrLn Included from Stuff64


 It's a bit tricky. Since the C preprocessor is run after the unlit, the
 included code should not have bird-tracks, also you have to get the
 indentation right. There's probably a way to run cpp before unlit, which
 would allow you to have bird-tracks in the #include'd code.

 Much easier with LaTeX-style literate code.

 Cheers,
 Daniel

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


Re: [Haskell-cafe] How to #include into .lhs files?

2011-02-03 Thread Michael Snoyman
My guess (a complete guess) is that the deliterate step is creating a
temporary .hs file elsewhere on your filesystem, which is why the CPP
step can't find B.hs without a fully-qualified path.

Michael

On Fri, Feb 4, 2011 at 6:56 AM, Conal Elliott co...@conal.net wrote:
 Thanks, Daniel. I'm still stumped. When I say

 #include B.hs

 in a .hs file, all works fine, but when in a .lhs file I get error: B.hs:
 No such file or directory. The file B.hs is in the same directory as the
 including file, which is the current directory for ghci. Same situation with
 ghc.

 If I change B.hs to ./B.hs, I get the same behavior. Only if I use a
 fully qualified path name for B.hs does it get found from the .lhs file.

 I'm using GHC 6.12.3 on Mac OS 10.6.6.

 Any ideas? (Anyone, not just Daniel.)

 Thanks,  - Conal


 On Thu, Feb 3, 2011 at 2:51 AM, Daniel Fischer
 daniel.is.fisc...@googlemail.com wrote:

 On Thursday 03 February 2011 10:33:23, Conal Elliott wrote:
  Does anyone have a working example of #include'ing Haskell code into a
  bird-tracks-style .lhs file with GHC? Every way I try leads to parsing
  errors. Is there documentation about how it's supposed to work?
 
  Help much appreciated.   - Conal

 Stupid example:

 -- Main:

  {-# LANGUAGE CPP #-}
  module Main (main) where

 #include MachDeps.h

  main :: IO ()
  main = do

 #if WORD_SIZE_IN_BITS == 32

      putStrLn 32 bits

 #include Stuff32

 # else

      putStrLn 64 bits

 #include Stuff64
 #endif

 -- Stuff32:

      putStrLn Included from Stuff32

 -- Stuff64:

      putStrLn Included from Stuff64


 It's a bit tricky. Since the C preprocessor is run after the unlit, the
 included code should not have bird-tracks, also you have to get the
 indentation right. There's probably a way to run cpp before unlit, which
 would allow you to have bird-tracks in the #include'd code.

 Much easier with LaTeX-style literate code.

 Cheers,
 Daniel


 ___
 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] AES on 32-bit system

2011-02-03 Thread Michael Snoyman
Hi everyone,

Does anyone else have trouble installing the AES package on a 32-bit
system? My system at home installs it just fine, but my VPS chokes
with the following error messages (plus a bunch of warnings):

cbits/ctr_inc.c:11:0:
 error: 'uint_64t' undeclared (first use in this function)

cbits/ctr_inc.c:11:0:
 error: (Each undeclared identifier is reported only once

cbits/ctr_inc.c:11:0:  error: for each function it appears in.)

cbits/ctr_inc.c:11:0:
 error: 'ctr' undeclared (first use in this function)

cbits/ctr_inc.c:11:0:  error: expected expression before ')' token

It's actually for this very reason that I'm still maintaining the
OpenSSL backend for http-enumerator: I think the tls package is stable
enough now to be used in production environments (kudos to Vincent by
the way). However, I can't use it in production if I can't build one
of its dependencies. This bug is also preventing me from adding some
nice features to http-enumerator, such as checking validity of SSL
certificates.

Anyone have any thoughts?

Michael

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


Re: [Haskell-cafe] AES on 32-bit system

2011-02-03 Thread Daniel Peebles
Knowing nothing about the package or its code, it looks like a typo to me.
The stdint.h naming of types would have it be uint64_t, not uint_64t. Could
that be it?

On Fri, Feb 4, 2011 at 6:00 AM, Michael Snoyman mich...@snoyman.com wrote:

 Hi everyone,

 Does anyone else have trouble installing the AES package on a 32-bit
 system? My system at home installs it just fine, but my VPS chokes
 with the following error messages (plus a bunch of warnings):

 cbits/ctr_inc.c:11:0:
 error: 'uint_64t' undeclared (first use in this function)

 cbits/ctr_inc.c:11:0:
 error: (Each undeclared identifier is reported only once

 cbits/ctr_inc.c:11:0:  error: for each function it appears in.)

 cbits/ctr_inc.c:11:0:
 error: 'ctr' undeclared (first use in this function)

 cbits/ctr_inc.c:11:0:  error: expected expression before ')' token

 It's actually for this very reason that I'm still maintaining the
 OpenSSL backend for http-enumerator: I think the tls package is stable
 enough now to be used in production environments (kudos to Vincent by
 the way). However, I can't use it in production if I can't build one
 of its dependencies. This bug is also preventing me from adding some
 nice features to http-enumerator, such as checking validity of SSL
 certificates.

 Anyone have any thoughts?

 Michael

 ___
 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] AES on 32-bit system

2011-02-03 Thread Michael Snoyman
Wow, I thought I'd tried that before, I guess not. Yes, that compiles,
and an initial test seems that it does not break at runtime either.
I'll email the author and see if he can make that change.

Michael

On Fri, Feb 4, 2011 at 8:11 AM, Daniel Peebles pumpkin...@gmail.com wrote:
 Knowing nothing about the package or its code, it looks like a typo to me.
 The stdint.h naming of types would have it be uint64_t, not uint_64t. Could
 that be it?

 On Fri, Feb 4, 2011 at 6:00 AM, Michael Snoyman mich...@snoyman.com wrote:

 Hi everyone,

 Does anyone else have trouble installing the AES package on a 32-bit
 system? My system at home installs it just fine, but my VPS chokes
 with the following error messages (plus a bunch of warnings):

 cbits/ctr_inc.c:11:0:
     error: 'uint_64t' undeclared (first use in this function)

 cbits/ctr_inc.c:11:0:
     error: (Each undeclared identifier is reported only once

 cbits/ctr_inc.c:11:0:  error: for each function it appears in.)

 cbits/ctr_inc.c:11:0:
     error: 'ctr' undeclared (first use in this function)

 cbits/ctr_inc.c:11:0:  error: expected expression before ')' token

 It's actually for this very reason that I'm still maintaining the
 OpenSSL backend for http-enumerator: I think the tls package is stable
 enough now to be used in production environments (kudos to Vincent by
 the way). However, I can't use it in production if I can't build one
 of its dependencies. This bug is also preventing me from adding some
 nice features to http-enumerator, such as checking validity of SSL
 certificates.

 Anyone have any thoughts?

 Michael

 ___
 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] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread C K Kashyap

 FrameBufferUpdateRequest x=0, y=0 width =1, height=1
 FrameBufferUpdateRequest x=1, y=0 width =99, height=1
 FrameBufferUpdateRequest x=0, y=1 width =100, height=99
 Main: socket: 7: hPutBuf: resource vanished (Connection reset by peer)


I was not taking care of partial updates, I've taken care of it now.  Btw,
what vncviewer are you using?

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


Re: [Haskell-cafe] OSX i386/x86 and x86_64 - time to switch supported platforms?

2011-02-03 Thread Mark Lentczner

On Feb 3, 2011, at 5:55 PM, Max Cantor wrote:
 Yes.  I'm saying that I believe that OSX x86_64 should be the officially 
 supported platform instead of 32-bit x86 with all the associated guarantees 
 and assurances.   I wanted to see how people felt about that.

I don't think this is such a good idea.

There are plenty of Macs in the field that can only execute 32bit code. (I'm 
typing on one right now!) Anyone wanting to produce binaries that they can 
distribute or deploy will need an environment that produces either 32bit only 
binaries, or multi-arch 32bit/64bit binaries.

My understanding is that GHC is quite a long way, if ever, from producing 
multi-arch binaries from a single compiler. To produce multi-arch binaries 
you'd need to install two copies of the GHC (one 32bit, one 64bit), build your 
code twice, once with each, and stitch the results together with lipo.

Hence, for the Haskell developer needing to deploy code, the path of least 
resistance is going to be simply compiling and distributing 32bit for awhile.

Because of this, the 32bit version should be officially supported just as much 
as the 64bit for at least the next few years.

My plan for the upcoming Haskell Platform is to build and distribute two 
installers: one 32bit and 64bit. Most developers should take the 64bit one if 
their machine supports it. Developers with older machines, and those building 
binary distributions will need to take the 32bit.

- Mark


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


[Haskell-cafe] Problem cabal installing wxcore with ghc 7.0.1 on linux x86_64

2011-02-03 Thread Alexander McPhail
zen:~# cabal install wxcore --enable-documentation --global
Resolving dependencies...
[1 of 1] Compiling Main (
/tmp/wxcore-0.12.1.617977/wxcore-0.12.1.6/Setup.hs,
/tmp/wxcore-0.12.1.617977/wxcore-0.12.1.6/dist/setup/Main.o )
Linking /tmp/wxcore-0.12.1.617977/wxcore-0.12.1.6/dist/setup/setup ...
generating: src/haskell/Graphics/UI/WXCore/WxcClassTypes.hs
reading class definitions:
parsing: src/include/wxc.h
parsing: src/include/wxc_types.h
parsing: src/include/wxc_glue.h
parsing: src/include/db.h
parsing: src/include/dragimage.h
parsing: src/include/graphicscontext.h
parsing: src/include/sound.h
parsing: src/include/managed.h
parsing: src/include/mediactrl.h
parsing: src/include/previewframe.h
parsing: src/include/printout.h
parsing: src/include/textstream.h
parsing: src/include/stc.h
parsing: src/include/stc_gen.h
generated 539 class definitions.
ok.
generating: src/haskell/Graphics/UI/WXCore/WxcClassInfo.hs
reading class definitions:
parsing: src/include/wxc.h
parsing: src/include/wxc_types.h
parsing: src/include/wxc_glue.h
parsing: src/include/db.h
parsing: src/include/dragimage.h
parsing: src/include/graphicscontext.h
parsing: src/include/sound.h
parsing: src/include/managed.h
parsing: src/include/mediactrl.h
parsing: src/include/previewframe.h
parsing: src/include/printout.h
parsing: src/include/textstream.h
parsing: src/include/stc.h
parsing: src/include/stc_gen.h
generated 381 class info definitions
ok.
parsing: src/include/wxc.h
parsing: src/include/wxc_types.h
parsing: src/include/wxc_glue.h
parsing: src/include/db.h
parsing: src/include/dragimage.h
parsing: src/include/graphicscontext.h
parsing: src/include/sound.h
parsing: src/include/managed.h
parsing: src/include/mediactrl.h
parsing: src/include/previewframe.h
parsing: src/include/printout.h
parsing: src/include/textstream.h
parsing: src/include/stc.h
parsing: src/include/stc_gen.h
ignore: parse error : //WXCOLORREF wxColour_GetPixel( TSelf(wxColour) _obj
);
generating: src/haskell/Graphics/UI/WXCore/WxcClassesAL.hs
reading class definitions:
parsing: src/include/wxc.h
parsing: src/include/wxc_types.h
parsing: src/include/wxc_glue.h
parsing: src/include/db.h
parsing: src/include/dragimage.h
parsing: src/include/graphicscontext.h
parsing: src/include/sound.h
parsing: src/include/managed.h
parsing: src/include/mediactrl.h
parsing: src/include/previewframe.h
parsing: src/include/printout.h
parsing: src/include/textstream.h
parsing: src/include/stc.h
parsing: src/include/stc_gen.h
generated 1560 methods for 120 classes.
generating: src/haskell/Graphics/UI/WXCore/WxcClassesMZ.hs
generated 2184 methods for 123 classes.
generating: src/haskell/Graphics/UI/WXCore/WxcClasses.hs
generated 3744 total methods for 243 total classes.
ok.
parsing: src/eiffel/wxc_defs.e
parsing: src/eiffel/wx_defs.e
parsing: src/eiffel/stc.e
generating: src/haskell/Graphics/UI/WXCore/WxcDefs.hs
generated 2454 constant definitions
ok.
setup: failed
cabal: Error: some packages failed to install:
wxcore-0.12.1.6 failed during the configure step. The exception was:
ExitFailure 1
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Byte Histogram

2011-02-03 Thread Johan Tibell
On Thu, Feb 3, 2011 at 11:40 PM, Richard O'Keefe o...@cs.otago.ac.nz wrote:
 Back in the days when systems other than Wintel and maybe sort of intel Linux 
 were
 supported by Clean, I used to really love one of the features of the Clean 
 compiler.
 One simple command line switch and the compiler would list the names of all 
 your
 top level functions together with their types, and the types included 
 strictness.
 (Also uniqueness, not relevant to Haskell.)

 The GHC documentation says the information is in the interface files,
 but they are binary now, and I can't find it there.

ghc --show-iface HI_FILE

The strictness signatures are a bit hard to parse though. Having a
cheat sheet would be nice.

Johan

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


Re: [Haskell-cafe] Byte Histogram

2011-02-03 Thread Johan Tibell
On Fri, Feb 4, 2011 at 12:38 AM, Erik de Castro Lopo
mle...@mega-nerd.com wrote:
 However, one of the Haskell projects I work on is Ben Lippmeier's
 DDC compiler. Thats about 5 lines of Haskell code and finding
 performance issues there is really difficult.

Right. It can still be tricky. I think we can get rid of a large
number of strictness issues by using strict data structures more
often, this should help beginners in particular. For the rest better
tooling would help. For example, a lint tool that marked up code with
the strictness information inferred by the compiler would be useful. I
had time to write one I would make the output look like HPC html
reports, with one color for strict function arguments and one color
for lazy function arguments.

Johan

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


Re: [Haskell-cafe] Instancing Typeable for monad transformers?

2011-02-03 Thread Ryan Ingram
Can you just wrap it?  Something like this:

-- put your monad type here
type M a = Iteratee ... a

data W a = W (Iteratee ... a) deriving Typeable
unW (W x) = x

toDynW :: Typeable a = M a - Dynamic
toDynW x = toDynamic (W x)

castM :: (Typeable x, Typeable a) = x - Maybe (M a)
castM = unW . cast

  -- ryan

On Tue, Feb 1, 2011 at 10:02 PM, John Millikin jmilli...@gmail.com wrote:
 Is there any reasonable way to do this if I want to cast a monadic
 value? For example:

 castState :: (Typeable a, Typeable s, Typeable1 m, Typeable b) = a - Maybe 
 (StateT s m b)
 castState = Data.Typeable.cast

 None of the common monad transformers declare instances of Typeable,
 so I don't know if the concept itself even works.

 The use case here is one of my library users wants to return an
 Iteratee from code running in hint, which requires any extracted
 values be typeable. My first attempt at an extension-free instance is
 something like this:

 import Data.Enumerator
 import Data.Typeable

 instance (Typeable a, Typeable1 m) = Typeable1 (Iteratee a m) where
       typeOf1 i = rep where
               typed :: (a - b) - b - a - a
               typed _ _ a = a

               ia :: a - Iteratee a m b
               ia = undefined

               im :: m c - Iteratee a m b
               im = undefined

               rep = mkTyConApp (mkTyCon Data.Enumerator.Iteratee) [tyA, 
 tyM]
               tyA = typeOf (typed ia i undefined)
               tyM = typeOf1 (typed im i undefined)

 which, besides being ugly, I have no idea if it's correct.

 ___
 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