Re: [Haskell-cafe] Conduit Error Output: Control.Monad.Trans.Resource.stateCleanup

2012-02-21 Thread Michael Snoyman
Hi Lyndon,

Outputting nothing *is* the desired result. When you run something like:

bar - runResourceT $ lazyConsume $ sourceFile foo.txt
print bar

The steps that occur are roughly[1]:

* ResourceT is initialized
* File handle is opened, release action is registered to close the file handle
* unsafeInterleaveIO is called, which creates a thunk that will pull
from the Handle
* runResourceT is called, which calls all release actions, including
closing the file handle
* The thunk is evaluated. It checks if the ResourceT is open. Since it
isn't, it returns a [].

The problem previously is that the last step was not checking if the
ResourceT was still open, which could result in pulling from a closed
handle.

Michael

On Tue, Feb 21, 2012 at 9:57 AM, Lyndon Maydwell maydw...@gmail.com wrote:
 Hi Michael,


 The behaviour of my original code has now changed to output nothing
 with no errors. I'm not sure of the significance of this as my code
 was incorrect, however, using the code you demonstrated gives the
 desired results.

 Thanks for the blindingly quick response!


 On Tue, Feb 21, 2012 at 3:30 PM, Michael Snoyman mich...@snoyman.com wrote:
 On Tue, Feb 21, 2012 at 7:40 AM, Michael Snoyman mich...@snoyman.com wrote:
 On Tue, Feb 21, 2012 at 5:46 AM, Lyndon Maydwell maydw...@gmail.com wrote:
 Hi Michael, Café.

 I'm writing some code using the conduit library and am encountering
 the following error output (while the program appears to function
 correctly) when using Data.Conduit.Lazy.

 The error given is:

 profile_simple_test_data: Control.Monad.Trans.Resource.stateCleanup: 
 There is a bug in the implementation. The mutable state is being accessed 
 after cleanup. Please contact the maintainers.

 A reduced code snippet that generates this error is (also attached):

 import Control.Monad
 import System.Environment
 import Control.Monad.IO.Class (liftIO)
 import System.IO
 import Data.Conduit.Lazy
 import Data.List (sort)

 import Data.Conduit

 import Prelude hiding (map)

 main = getArgs = process

 process args = mapM_ sorted args

 sorted x = runResourceT (lazyConsume $ sourceFeed x) = (mapM_ print . 
 id)

 sourceFeed :: ResourceIO m = FilePath - Source m String
 sourceFeed file = sourceIO
     (openFile file ReadMode)
     hClose
     (\h - liftIO $ do
         eof - hIsEOF h
         if eof
             then return IOClosed
             else fmap IOOpen $ hGetLine h)

 when run over any text file.

 I may be doing something inconsistent with the correct use of sourceIO
 or lazyConsume, however, I tried to follow the example at
 http://www.yesodweb.com/home/snoyberg/blogs/conduit/conduit/source/source.ditamap?nav=nav-2
 as closely as possible.

 Is this a bug, or simply an incorrect use of Conduit?

 I haven't fully debugged this yet. There's certainly a bug in the
 implementation of ResourceT, but the sample program is also wrong. You
 can't pass the result from a call to lazyConsume outside the scope of
 its ResourceT; the correct way to write sorted would be:

    sorted x = runResourceT $ lazyConsume (sourceFeed x) = mapM_
 (liftIO . print)

 My guess is that this is a fallout from the transition away from
 mutable variables: lazyConsume no longer has any way of knowing that
 its ResourceT has already been terminated. Perhaps a simple solution
 would be to expose a primitive that checks if the ResourceT block has
 already been finalized.

 Michael

 I've added a test case for this bug, and fixed it. The commit is:

 https://github.com/snoyberg/conduit/commit/87e890fe7ee58686d20cabba15dd37f18ba66620

 The basic idea is to add an extra constructor to represent when the
 ResourceT has already been closed, and expose a function
 resourceActive to check the state. Can you check if this solves your
 problem?

 Michael

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


Re: [Haskell-cafe] Conduit Error Output: Control.Monad.Trans.Resource.stateCleanup

2012-02-21 Thread Lyndon Maydwell
That makes a lot of sense.

The diff was a bit beyond my skimming abilities :-)

On Tue, Feb 21, 2012 at 4:15 PM, Michael Snoyman mich...@snoyman.com wrote:
 Hi Lyndon,

 Outputting nothing *is* the desired result. When you run something like:

    bar - runResourceT $ lazyConsume $ sourceFile foo.txt
    print bar

 The steps that occur are roughly[1]:

 * ResourceT is initialized
 * File handle is opened, release action is registered to close the file handle
 * unsafeInterleaveIO is called, which creates a thunk that will pull
 from the Handle
 * runResourceT is called, which calls all release actions, including
 closing the file handle
 * The thunk is evaluated. It checks if the ResourceT is open. Since it
 isn't, it returns a [].

 The problem previously is that the last step was not checking if the
 ResourceT was still open, which could result in pulling from a closed
 handle.

 Michael

 On Tue, Feb 21, 2012 at 9:57 AM, Lyndon Maydwell maydw...@gmail.com wrote:
 Hi Michael,


 The behaviour of my original code has now changed to output nothing
 with no errors. I'm not sure of the significance of this as my code
 was incorrect, however, using the code you demonstrated gives the
 desired results.

 Thanks for the blindingly quick response!


 On Tue, Feb 21, 2012 at 3:30 PM, Michael Snoyman mich...@snoyman.com wrote:
 On Tue, Feb 21, 2012 at 7:40 AM, Michael Snoyman mich...@snoyman.com 
 wrote:
 On Tue, Feb 21, 2012 at 5:46 AM, Lyndon Maydwell maydw...@gmail.com 
 wrote:
 Hi Michael, Café.

 I'm writing some code using the conduit library and am encountering
 the following error output (while the program appears to function
 correctly) when using Data.Conduit.Lazy.

 The error given is:

 profile_simple_test_data: Control.Monad.Trans.Resource.stateCleanup: 
 There is a bug in the implementation. The mutable state is being 
 accessed after cleanup. Please contact the maintainers.

 A reduced code snippet that generates this error is (also attached):

 import Control.Monad
 import System.Environment
 import Control.Monad.IO.Class (liftIO)
 import System.IO
 import Data.Conduit.Lazy
 import Data.List (sort)

 import Data.Conduit

 import Prelude hiding (map)

 main = getArgs = process

 process args = mapM_ sorted args

 sorted x = runResourceT (lazyConsume $ sourceFeed x) = (mapM_ print . 
 id)

 sourceFeed :: ResourceIO m = FilePath - Source m String
 sourceFeed file = sourceIO
     (openFile file ReadMode)
     hClose
     (\h - liftIO $ do
         eof - hIsEOF h
         if eof
             then return IOClosed
             else fmap IOOpen $ hGetLine h)

 when run over any text file.

 I may be doing something inconsistent with the correct use of sourceIO
 or lazyConsume, however, I tried to follow the example at
 http://www.yesodweb.com/home/snoyberg/blogs/conduit/conduit/source/source.ditamap?nav=nav-2
 as closely as possible.

 Is this a bug, or simply an incorrect use of Conduit?

 I haven't fully debugged this yet. There's certainly a bug in the
 implementation of ResourceT, but the sample program is also wrong. You
 can't pass the result from a call to lazyConsume outside the scope of
 its ResourceT; the correct way to write sorted would be:

    sorted x = runResourceT $ lazyConsume (sourceFeed x) = mapM_
 (liftIO . print)

 My guess is that this is a fallout from the transition away from
 mutable variables: lazyConsume no longer has any way of knowing that
 its ResourceT has already been terminated. Perhaps a simple solution
 would be to expose a primitive that checks if the ResourceT block has
 already been finalized.

 Michael

 I've added a test case for this bug, and fixed it. The commit is:

 https://github.com/snoyberg/conduit/commit/87e890fe7ee58686d20cabba15dd37f18ba66620

 The basic idea is to add an extra constructor to represent when the
 ResourceT has already been closed, and expose a function
 resourceActive to check the state. Can you check if this solves your
 problem?

 Michael

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


Re: [Haskell-cafe] Haskell development in Mac OS X after Gatekeeper

2012-02-21 Thread Manuel M T Chakravarty
Austin Seipp:
 The only two things not clear at this point, at least to me, are:
 
 1) Will Apple require the paid development program, as opposed to the
 free one, if you only want to self-sign applications with a cert they
 trust?

You can self-sign applications with a certificate that you get with a free 
developer ID.

Cf. http://daringfireball.net/2012/02/mountain_lion
 Apple is calling it “Gatekeeper”. It’s a system whereby developers can sign 
 up for free-of-charge Apple developer IDs which they can then use to 
 cryptographically sign their applications. If an app is found to be malware, 
 Apple can revoke that developer’s certificate, rendering the app (along with 
 any others from the same developer) inert on any Mac where it’s been 
 installed. In effect, it offers all the security benefits of the App Store, 
 except for the process of approving apps by Apple.

 2) What will the default Gatekeeper setting in Mountain Lion be?

The default is the middle option — i.e., AppStore and self-signed apps run.

From the same source,
 The default for this setting is, I say, exactly right: the one in the 
 middle, disallowing only unsigned apps. This default setting benefits users 
 by increasing practical security, and also benefits developers, preserving 
 the freedom to ship whatever software they want for the Mac, with no 
 approval process.

 In an ideal world, you won't require the paid dev ID (I
 don't know the expense of giving out certs however,) and the default
 setting would be App store + Dev signed.

It is an ideal world :)

Manuel


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


Re: [Haskell-cafe] Haskell development in Mac OS X after Gatekeeper

2012-02-21 Thread Manuel M T Chakravarty
Austin Seipp:
 On Sun, Feb 19, 2012 at 8:39 PM, Tom Murphy amin...@gmail.com wrote:
 On the other hand,
 it's impossible for a software company to maintain a sense of
 professionalism, when a user has to know a weird secret handshake to
 disable what they may perceive as equivalent to antivirus software.
 
 I'll also just add that if you're an actual software company, large or
 small, the $100 for the developer ID, certificate, ability to do
 iOS/App store apps, whatever, is a business expense, that is utterly
 dominated by a million other factors, as developing high quality
 applications isn't exactly cheap, and the price of a license is really
 the last thing you're going to worry about.
 
 If you're more worried about the potential to impact individual
 developers and small open source teams who want to get their work out
 there, you are right it's a concern.

I think, Apple has made their stance quite clear by releasing the command line 
dev tools:

  http://kennethreitz.com/xcode-gcc-and-homebrew.html

Manuel


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


[Haskell-cafe] (no subject)

2012-02-21 Thread M. R

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


Re: [Haskell-cafe] ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

2012-02-21 Thread Mats Rauhala
You mentioned that haskelldb was the first library where you weren't
forced to break the abstraction. Do you have a solution to a situation
where you might want to retreive the last inserted id after an insert?

-- 
Mats Rauhala
MasseR


pgp8ofM61Yw5k.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] how to add monad-stack to network-conduit

2012-02-21 Thread Alexander V Vershilov
Hello.

I have got next problem: I want to have database connection pool
in server based on network-conduit. 
So I wanted to be able to do

 runTCPServer options action 
   where 
 action src snk = 
   pool - ask
   
   

In this situation I can make pool `action's parameter, but in more
difficult situations (many methods inside) is would be painfull.

Also I wanted to have some kind of State for each thread, e.g.

 action src snk = src $= act1 $= act2 $= act3 $$ snk

in act1, act2, act3 I want to read and change state.

Is it possible? And how to do it if it is?

--
Alexander Vershilov


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


Re: [Haskell-cafe] types and number of evaluation steps

2012-02-21 Thread Jake McArthur
My understanding was that the reason is that CSE can cause things to be
shared that take up a lot of space when normally they would be garbage
collected sooner.
On Feb 18, 2012 11:57 AM, Roman Cheplyaka r...@ro-che.info wrote:

 It doesn't matter. Laziness would be affected if, for instance,
 something is not evaluated without CSE and is evaluated with it.

 In your example either all or none of 'a' and 'b' get evaluated,
 depending on whether the top-level expression is evaluated.

 * Victor Gorokgov m...@rkit.pp.ru [2012-02-18 18:23:19+0400]
  example = a + b + a + b
 
  exampleCSE = x + x
where x = a + b
 
  With CSE we are introducing new thunk: x.
 
  18.02.2012 17:38, Roman Cheplyaka пишет:
  * Holger Siegelholgersiege...@yahoo.de  [2012-02-18 12:52:08+0100]
  You cannot. Common subexpression elimination is done by GHC very
  conservatively, because it can not only affect impure programs: it can
  also affects strictness/lazyness and worsen memory usage of pure code.
  Like the HaskellWiki says: If you care about CSE, do it by hand.
  How can it affect strictness or laziness?

 --
 Roman I. Cheplyaka :: http://ro-che.info/

 ___
 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] podcast?

2012-02-21 Thread Mats Rauhala
On 09:05 Wed 15 Feb , serialhex wrote:
 Does anybody know of any good haskell/fp podcasts out there?  i dont know
 if my googling skillz are just failing me, but i can't seem to find
 anything.  thanks all!
 hex

Out of my head I can think of ThinkRelevance podcast at
http://thinkrelevance.com/blog/tags/podcast


pgpSaQMQOTtoX.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] podcast?

2012-02-21 Thread Christopher Done
I recently thought it would be Pretty Cool to make an FP podcast, sort
of a spoken Haskell Weekly News but covering all FP, blogs, packages,
conferences, papers, standards, mailing lists, even stackoverflow,
whatever's interesting in FP. We could use Gtalk or Mumble (both quite
high quality audio) to conduct it and cut it up in audacity.

On 21 February 2012 15:00, Mats Rauhala mats.rauh...@gmail.com wrote:
 On 09:05 Wed 15 Feb     , serialhex wrote:
 Does anybody know of any good haskell/fp podcasts out there?  i dont know
 if my googling skillz are just failing me, but i can't seem to find
 anything.  thanks all!
 hex

 Out of my head I can think of ThinkRelevance podcast at
 http://thinkrelevance.com/blog/tags/podcast

 ___
 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] podcast?

2012-02-21 Thread Mats Rauhala
On 15:15 Tue 21 Feb , Christopher Done wrote:
 I recently thought it would be Pretty Cool to make an FP podcast, sort
 of a spoken Haskell Weekly News but covering all FP, blogs, packages,
 conferences, papers, standards, mailing lists, even stackoverflow,
 whatever's interesting in FP. We could use Gtalk or Mumble (both quite
 high quality audio) to conduct it and cut it up in audacity.

I for one would be an interested listener

-- 
Mats Rauhala
MasseR


pgpmnNX9qw0my.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monad laws in presence of bottoms

2012-02-21 Thread wren ng thornton

On 2/21/12 2:17 AM, Roman Cheplyaka wrote:

* Sebastian Fischerfisc...@nii.ac.jp  [2012-02-21 00:28:13+0100]

On Mon, Feb 20, 2012 at 7:42 PM, Roman Cheplyakar...@ro-che.info  wrote:


Is there any other interpretation in which the Reader monad obeys the
laws?



If selective strictness (the  seq  combinator) would exclude function
types, the difference between  undefined  and  \_ -  undefined  could not
be observed. This reminds me of the different language levels used by the
free theorem generator [1] and the discussions whether  seq  should have a
type-class constraint..


It's not just about functions. The same holds for the lazy Writer monad,
for instance.


That's a similar sort of issue, just about whether undefined == 
(undefined,undefined) or not. If the equality holds then tuples would be 
domain products[1], but domain products do not form domains! In order to 
get a product which does form a domain, we'd need to use the smash 
product[2] instead. Unfortunately we can't have our cake and eat it too 
(unless we get rid of bottom entirely).


Both this issue and the undefined == (\_ - undefined) issue come down 
to whether we're allowed to eta expand functions or tuples/records. 
While this is a well-studies topic, I don't know that anyone's come up 
with a really pretty answer to the dilemma.



[1] Also a category-theoretic product.

[2] Aka: data SmashProduct a b = SmashProduct !a !b

--
Live well,
~wren

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


[Haskell-cafe] Preventing leaked open file descriptors when catching exceptions

2012-02-21 Thread Ryan Newton
Hi all,

I'm trying to run a loop that repeatedly attempts to open a file until it
succeeds.  The file is a named pipe in nonblocking mode, so the writer can
only connect after the reader has connected.  (Perhaps there is some way to
determine this by stat'ing the pipe, but I don't know it yet.)

Thus I do something like the following:

 tryUntilNoIOErr $ do
performGC
-- The reader must connect first, the writer here spins with backoff.
PIO.openFd filename PIO.WriteOnly Nothing fileFlags

I'm running GC between iterations to try to make sure I get rid of open
files.  Also, in the tryUntilNoIOErr code below I have some debugging
messages which indicate that ioeGetHandle reports no handles associated
with the exceptions I'm getting back.  (If there were handles provided I
could close them explicitly.)

In spite of these attempted precautions I'm seeing too many open files
exceptions in simple benchmarks that should only have a maximum of ONE file
open.

Any hints / pointers?

Thanks,
  -Ryan


mkBackoff :: IO (IO ())
mkBackoff =
  do tref - newIORef 1
 return$ do t - readIORef tref
writeIORef tref (min maxwait (2 * t))
threadDelay t
 where
   maxwait = 50 * 1000

tryUntilNoIOErr :: IO a - IO a
tryUntilNoIOErr action = mkBackoff = loop
 where
  loop bkoff =
handle (\ (e :: IOException) -
 do bkoff
BSS.hPutStr stderr$ BSS.pack$ got IO err:  ++ show e
case ioeGetHandle e of
  Nothing - BSS.hPutStrLn stderr$ BSS.pack$   no hndl io err.
  Just x  - BSS.hPutStrLn stderr$ BSS.pack$   HNDL on io
err! ++ show x
loop bkoff) $
   action
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Preventing leaked open file descriptors when catching exceptions

2012-02-21 Thread Ryan Newton
FYI, lsof confirms that there are indeed many many open connections to the
same FIFO:

Is there some other way to get at (and clean up) the file descriptor that
is left by System.Posix.IO.openFD after it throws an exception?

PingPipes 25115  rrnewton  124r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  125r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  126r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  127r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  128r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  129r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  130r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  131r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  132r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  133r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  134r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  135r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  136r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  137r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683
PingPipes 25115  rrnewton  138r FIFO8,2  0t0   25166171
/tmp/pipe_9083984821255795683


On Tue, Feb 21, 2012 at 11:13 AM, Ryan Newton rrnew...@gmail.com wrote:

 Hi all,

 I'm trying to run a loop that repeatedly attempts to open a file until it
 succeeds.  The file is a named pipe in nonblocking mode, so the writer can
 only connect after the reader has connected.  (Perhaps there is some way to
 determine this by stat'ing the pipe, but I don't know it yet.)

 Thus I do something like the following:

  tryUntilNoIOErr $ do
 performGC
 -- The reader must connect first, the writer here spins with backoff.
 PIO.openFd filename PIO.WriteOnly Nothing fileFlags

 I'm running GC between iterations to try to make sure I get rid of open
 files.  Also, in the tryUntilNoIOErr code below I have some debugging
 messages which indicate that ioeGetHandle reports no handles associated
 with the exceptions I'm getting back.  (If there were handles provided I
 could close them explicitly.)

 In spite of these attempted precautions I'm seeing too many open files
 exceptions in simple benchmarks that should only have a maximum of ONE file
 open.

 Any hints / pointers?

 Thanks,
   -Ryan


 mkBackoff :: IO (IO ())
 mkBackoff =
   do tref - newIORef 1
  return$ do t - readIORef tref
 writeIORef tref (min maxwait (2 * t))
 threadDelay t
  where
maxwait = 50 * 1000

 tryUntilNoIOErr :: IO a - IO a
 tryUntilNoIOErr action = mkBackoff = loop
  where
   loop bkoff =
 handle (\ (e :: IOException) -
  do bkoff
 BSS.hPutStr stderr$ BSS.pack$ got IO err:  ++ show e
 case ioeGetHandle e of
   Nothing - BSS.hPutStrLn stderr$ BSS.pack$   no hndl io
 err.
   Just x  - BSS.hPutStrLn stderr$ BSS.pack$   HNDL on io
 err! ++ show x
 loop bkoff) $
action


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


Re: [Haskell-cafe] Monad laws in presence of bottoms

2012-02-21 Thread MigMit
Ehm... why exactly don't domain products form domains?

On 21 Feb 2012, at 19:44, wren ng thornton wrote:

 On 2/21/12 2:17 AM, Roman Cheplyaka wrote:
 * Sebastian Fischerfisc...@nii.ac.jp  [2012-02-21 00:28:13+0100]
 On Mon, Feb 20, 2012 at 7:42 PM, Roman Cheplyakar...@ro-che.info  wrote:
 
 Is there any other interpretation in which the Reader monad obeys the
 laws?
 
 
 If selective strictness (the  seq  combinator) would exclude function
 types, the difference between  undefined  and  \_ -  undefined  could not
 be observed. This reminds me of the different language levels used by the
 free theorem generator [1] and the discussions whether  seq  should have a
 type-class constraint..
 
 It's not just about functions. The same holds for the lazy Writer monad,
 for instance.
 
 That's a similar sort of issue, just about whether undefined == 
 (undefined,undefined) or not. If the equality holds then tuples would be 
 domain products[1], but domain products do not form domains! In order to get 
 a product which does form a domain, we'd need to use the smash product[2] 
 instead. Unfortunately we can't have our cake and eat it too (unless we get 
 rid of bottom entirely).
 
 Both this issue and the undefined == (\_ - undefined) issue come down to 
 whether we're allowed to eta expand functions or tuples/records. While this 
 is a well-studies topic, I don't know that anyone's come up with a really 
 pretty answer to the dilemma.
 
 
 [1] Also a category-theoretic product.
 
 [2] Aka: data SmashProduct a b = SmashProduct !a !b
 
 -- 
 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] Monad laws in presence of bottoms

2012-02-21 Thread Dan Doel
On Tue, Feb 21, 2012 at 10:44 AM, wren ng thornton w...@freegeek.org wrote:
 That's a similar sort of issue, just about whether undefined ==
 (undefined,undefined) or not. If the equality holds then tuples would be
 domain products[1], but domain products do not form domains!
 ...
 [1] Also a category-theoretic product.

This doesn't make much sense to me, either. If it's a category
theoretic product in a category of domains, then the product must be a
domain, no?

 In order to get
 a product which does form a domain, we'd need to use the smash product[2]
 instead. Unfortunately we can't have our cake and eat it too (unless we get
 rid of bottom entirely).

You don't have to get rid of bottom entirely (I think). If you make
matches against products irrefutable, then you're again in the
situation of seq being the only thing able to distinguish between _|_
and (_|_, _|_), so we could keep the current implementation (which is
efficient) without it being possible to observe within the language.
You just have to make seq not be magic on products. Miranda did this,
except it still had a seq which exposed the lie.

The problem with this is that you can easily build up a product that
is a bunch of thunks and cause a stack overflow; I _think_ that's more
of a concern than doing the same with a function. So in practice it
might be harder to do without seq on tuples.

-- Dan

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


Re: [Haskell-cafe] Preventing leaked open file descriptors when catching exceptions

2012-02-21 Thread Bryan O'Sullivan
On Tue, Feb 21, 2012 at 8:16 AM, Ryan Newton rrnew...@gmail.com wrote:

 FYI, lsof confirms that there are indeed many many open connections to the
 same FIFO:


Like all of the lowest-level I/O functions, openFD just gives you back an
integer, and the Fd type has no notion that there's an underlying system
resource associated with it. It's your responsibility to manage it (i.e.
clean up manually when catching an exception).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Preventing leaked open file descriptors whencatching exceptions

2012-02-21 Thread Donn Cave
Quoth Bryan O'Sullivan b...@serpentine.com,
 On Tue, Feb 21, 2012 at 8:16 AM, Ryan Newton rrnew...@gmail.com wrote:

 FYI, lsof confirms that there are indeed many many open connections to the
 same FIFO:


 Like all of the lowest-level I/O functions, openFD just gives you back an
 integer, and the Fd type has no notion that there's an underlying system
 resource associated with it. It's your responsibility to manage it (i.e.
 clean up manually when catching an exception).

What's more - if I understood the hypothesis correctly, that the
exception occurs during openFd - that fails to return an Fd because
the open(2) system call fails to return one, so it would presumably
be an OS level bug if there's really an open file descriptor left
from this.

Donn

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


Re: [Haskell-cafe] Preventing leaked open file descriptors whencatching exceptions

2012-02-21 Thread Ryan Newton
Ah, thanks Bryan.  I hadn't looked into it enough to realize that FDs are
just ints and not ForeignPtrs w/ finalizers.

Re: Donn's point.  Well, yes, that would seem to be the case!  But since I
think a linux bug is unlikely, I'm afraid that there's something else going
on here which I am not thinking of.

I'll make a self contained test of this and send it out.


On Tue, Feb 21, 2012 at 12:53 PM, Donn Cave d...@avvanta.com wrote:

 Quoth Bryan O'Sullivan b...@serpentine.com,
  On Tue, Feb 21, 2012 at 8:16 AM, Ryan Newton rrnew...@gmail.com wrote:
 
  FYI, lsof confirms that there are indeed many many open connections to
 the
  same FIFO:
 
 
  Like all of the lowest-level I/O functions, openFD just gives you back an
  integer, and the Fd type has no notion that there's an underlying system
  resource associated with it. It's your responsibility to manage it (i.e.
  clean up manually when catching an exception).

 What's more - if I understood the hypothesis correctly, that the
 exception occurs during openFd - that fails to return an Fd because
 the open(2) system call fails to return one, so it would presumably
 be an OS level bug if there's really an open file descriptor left
 from this.

Donn

 ___
 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] Second Monad.Reader #20 call for copy

2012-02-21 Thread Edward Z. Yang
Second Call for Copy: The Monad.Reader - Issue 20
-

Whether you're an established academic or have only just started
learning Haskell, if you have something to say, please consider
writing an article for The Monad.Reader!  The submission deadline
for Issue 20 will be:

**Monday, March 5**

The Monad.Reader


The Monad.Reader is a electronic magazine about all things Haskell. It
is less formal than journal, but somehow more enduring than a wiki-
page. There have been a wide variety of articles: exciting code
fragments, intriguing puzzles, book reviews, tutorials, and even
half-baked research ideas.

Submission Details
~~

Get in touch with me if you intend to submit something -- the sooner
you let me know what you're up to, the better.

Please submit articles for the next issue to me by e-mail (ezy...@mit.edu).

Articles should be written according to the guidelines available from

http://themonadreader.wordpress.com/contributing/

Please submit your article in PDF, together with any source files you
used. The sources will be released together with the magazine under a
BSD license.

If you would like to submit an article, but have trouble with LaTeX
please let me know and we'll work something out.

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


Re: [Haskell-cafe] ANN: network-socket-options 0.1

2012-02-21 Thread Conrad Parker
On 21 February 2012 14:57, Joey Adams joeyadams3.14...@gmail.com wrote:
 I added a new package containing wrappers for getsockopt and setsockopt:

    http://hackage.haskell.org/package/network-socket-options

 The network package already has getSocketOption and setSocketOption.
 The problem is, these don't work for socket options that aren't
 represented by integers, such as SO_LINGER:

    http://trac.haskell.org/network/ticket/23

 Another, less serious problem is that getSocketOption and
 setSocketOption don't leverage the type system as well as they could.
 Many options are boolean values; it'd be better to get and set them
 with 'Bool's instead of 'Int's.

 network-socket-options implements options using getter and setter
 functions, e.g.:

    getLinger :: HasSocket sock = sock - IO (Maybe Seconds)

    setLinger :: HasSocket sock = sock - Maybe Seconds - IO ()

    type Seconds = Int

 The HasSocket type class is defined to overload the getters and
 setters to work on raw file descriptors, not just Socket objects.

 This functionality should probably go in the network package itself.
 However, I decided to release it as a separate package so I could
 start using it sooner.  If people like it enough, perhaps the network
 package can absorb it, as was done with network-bytestring.

Hi Joey,

awesome! I've prepared some patches for network to add this module and
its tests, in this branch:

https://github.com/kfish/network/tree/options

I didn't modify any other modules, perhaps Network.Socket.Options
should be re-exported from Network.Socket, and perhaps
{get,set}SocketOption should be deprecated?

network$ autoreconf
network$ cabal configure --enable-tests
network$ cabal build
network$ cabal test
Running 3 test suites...
Test suite options: RUNNING...
Test suite options: PASS
Test suite logged to: dist/test/network-2.3.0.11-options.log
Test suite uri: RUNNING...
Test suite uri: PASS
Test suite logged to: dist/test/network-2.3.0.11-uri.log
Test suite simple: RUNNING...
Test suite simple: PASS
Test suite logged to: dist/test/network-2.3.0.11-simple.log
3 of 3 test suites (3 of 3 test cases) passed.

Conrad.

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


Re: [Haskell-cafe] ANN: network-socket-options 0.1

2012-02-21 Thread Joey Adams
On Tue, Feb 21, 2012 at 7:36 PM, Conrad Parker con...@metadecks.org wrote:
 awesome! I've prepared some patches for network to add this module and
 its tests, in this branch:

 https://github.com/kfish/network/tree/options

Cool, thanks!

 I didn't modify any other modules, perhaps Network.Socket.Options
 should be re-exported from Network.Socket, and perhaps
 {get,set}SocketOption should be deprecated?

I agree with deprecating getSocketOption and setSocketOption.  Don't
remove them, just deprecate them.  Network.Socket.Options doesn't
implement all of the options {get,set}SocketOption has, yet (e.g.
RecvLowWater).

I'm not sure about re-exporting Network.Socket.Options, though.
That's a lot to dump into the namespace.  Particularly worrisome names
include:

* getError

* getType

Note the following:

 * I'm going to release network-socket-options 0.1.1 pretty soon.  It
will add higher-level functions for setting socket timeouts, to work
around the lack of a proper IO manager for Windows:

http://trac.haskell.org/network/ticket/2
http://trac.haskell.org/network/ticket/31#comment:1

 * Network.Socket has a getPeerCred function, which gets the
SO_PEERCRED socket option.  Perhaps it should be moved to
Network.Socket.Options (re-exported in Network.Socket for backward
compatibility) and generalized with HasSocket like the other options.

 * A couple of the tests in my test suite require root access.
Consider them optional, as they cover ground already pretty
well-covered by the other tests.

Thanks for the integration work.

-Joey

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


Re: [Haskell-cafe] network-2.3.0.10 compiled for ghc 7.4.1 windows

2012-02-21 Thread Matias Hernandez
Hi Alberto.

Do we need cygwin to install your compiled package? I thought not (I'm not 
very versed on this) but when I tried cabal install network after 
extracting it I got:

Configuring network-2.3.0.11...
cabal: The package has a './configure' script. This requires a Unix
compatibility toolchain such as MinGW+MSYS or Cygwin.
cabal: Error: some packages failed to install:
network-2.3.0.11 failed during the configure step. The exception was:
ExitFailure 1

Best regards, and thanks for any help!
- Matias
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need Help.

2012-02-21 Thread Chris Wong
Hello

On Tue, Feb 21, 2012 at 8:32 PM, Manoj Chaudhari manoj...@gmail.com wrote:
 Hi,

 We are looking for senior technical resources with skills in
 Haskell/Functional programming.
 Experience : 6 to 20 years,

 Job Location : Pune (India).

Out of curiosity, what will the job involve?

Also, it is bad netiquette to use bcc when you don't need to -- next
time, try entering Haskell Cafe in the to field instead.

Chris

 Regards!
 Manoj

 ___
 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] network-2.3.0.10 compiled for ghc 7.4.1 windows

2012-02-21 Thread Chris Wong
Hello Matias

On Wed, Feb 22, 2012 at 4:02 PM, Matias Hernandez mhern...@gmail.com wrote:
 Hi Alberto.

 Do we need cygwin to install your compiled package?

I don't believe you do. If memory doesn't fail me, the Haskell
Platform includes a compiler (MinGW), but not a shell (MSYS).

This page explains all: http://trac.haskell.org/haskell-platform/ticket/165

Chris

 I thought not (I'm not very versed on this) but when I tried cabal install 
 network after
 extracting it I got:

 Configuring network-2.3.0.11...
 cabal: The package has a './configure' script. This requires a Unix
 compatibility toolchain such as MinGW+MSYS or Cygwin.
 cabal: Error: some packages failed to install:
 network-2.3.0.11 failed during the configure step. The exception was:
 ExitFailure 1

 Best regards, and thanks for any help!
 - Matias

 ___
 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] network-2.3.0.10 compiled for ghc 7.4.1 windows

2012-02-21 Thread Sai Hemanth K
Hi,

you do need msys or cygwin for cabal installing network
msys at
http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.11/MSYS-1.0.11.exe/download
You will then have to follow the instructions at
http://www.mingw.org/wiki/MSYS. Please make sure that it uses ghc's mingw

thanks
Hemanth K




On Wed, Feb 22, 2012 at 8:32 AM, Matias Hernandez mhern...@gmail.comwrote:

 Hi Alberto.

 Do we need cygwin to install your compiled package? I thought not (I'm not
 very versed on this) but when I tried cabal install network after
 extracting it I got:

 Configuring network-2.3.0.11...
 cabal: The package has a './configure' script. This requires a Unix
 compatibility toolchain such as MinGW+MSYS or Cygwin.
 cabal: Error: some packages failed to install:
 network-2.3.0.11 failed during the configure step. The exception was:
 ExitFailure 1

 Best regards, and thanks for any help!
 - Matias

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




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


Re: [Haskell-cafe] ANN: hp2html, a tool for viewing GHC heap-profiles

2012-02-21 Thread Johan Tibell
On Tue, Feb 21, 2012 at 7:36 PM, Iavor Diatchki
iavor.diatc...@gmail.com wrote:
 Hello,

 I made a new version of `hp2html` (0.2), which shows the legend by default
 (take a look at at the attached screen shot).  If the legend is in the way,
 you can turn it off (and on) by clicking on the button at the top of the
 screen.

Nice!

-- Johan

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


Re: [Haskell-cafe] ANN: network-socket-options 0.1

2012-02-21 Thread Joey Adams
I released network-socket-options 0.2, adding setSocketTimeouts and
setHandleTimeouts.  I'll post an announcement in a separate thread
once the Haddock documentation is generated.

-Joey

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


Re: [Haskell-cafe] Haskell development in Mac OS X after Gatekeeper

2012-02-21 Thread wren ng thornton

On 2/19/12 10:44 PM, Jack Henahan wrote:

(or any other method which applies the quarantine flag)


And you can always use xattr in order to delete that flag, if need be.

--
Live well,
~wren

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


Re: [Haskell-cafe] Haskell development in Mac OS X after Gatekeeper

2012-02-21 Thread wren ng thornton

On 2/20/12 4:31 PM, Richard O'Keefe wrote:

On 20/02/2012, at 5:53 PM, Brandon Allbery wrote:

Bzuh?


Since you are running Lion and I am not, it isn't _that_ surprising that we
see different things.  It remains surprising that in 10.6.8 the xattr
command is there but its manual page is not.


The manpage is also missing on earlier versions (like my 10.5.8 laptop).

Though usually for things like this you can just pass -? and either (1) 
it'll be recognized so a help message will be displayed, or (2) it won't 
be recognized and hence a help message will be displayed. Passing -? is 
safer than trying to run the program with no options, since many 
programs will do stuff even without options/arguments.


--
Live well,
~wren

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


Re: [Haskell-cafe] Monad laws in presence of bottoms

2012-02-21 Thread wren ng thornton

On 2/21/12 11:27 AM, MigMit wrote:

Ehm... why exactly don't domain products form domains?


One important property of domains[1] is that they have a unique bottom 
element. Given domains A and B, let us denote the domain product as:


(A,B) def= { (a,b) | a - A, b - B }

Which will inherit an ordering in the obvious/free way from the domain 
orderings on A and B. Since both A and B are domains, they have bottom 
elements:


exists a0:A. forall a:A. (a0  =_A  a)
exists b0:B. forall b:B. (b0  =_B  b)

However, there is no free ordering on:

{ (a0,b) | b - B } \cup { (a,b0) | a - A }

So all of those are minimal elements of (A,B) but none of them is a 
unique minimum; hence (A,B) is not a domain.


The smash product gets around this because it takes all those elements 
and makes them equal, just like a strict tuple would in Haskell.



[1] This is in the sense of domain theory. It has nothing (per se) to do 
with the many other uses of the term domain in mathematics.


--
Live well,
~wren

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


Re: [Haskell-cafe] Monad laws in presence of bottoms

2012-02-21 Thread wren ng thornton

On 2/21/12 11:54 AM, Dan Doel wrote:

On Tue, Feb 21, 2012 at 10:44 AM, wren ng thorntonw...@freegeek.org  wrote:

That's a similar sort of issue, just about whether undefined ==
(undefined,undefined) or not. If the equality holds then tuples would be
domain products[1], but domain products do not form domains!
...
[1] Also a category-theoretic product.


This doesn't make much sense to me, either. If it's a category
theoretic product in a category of domains, then the product must be a
domain, no?


It's a category-theoretic product, but not for the category of domains. 
Let Set be the category of sets and set-theoretic functions. And let 
pDCPO be the category of (pointed) domains and their homomorphisms.


The category-theoretic product of A and B is just some triple (C, pi_A : 
C - A, pi_B : C - B) such that forall D, forall f : D - A, and forall 
g : D - B, there exists a unique h : D - C such that f = pi_A . h and 
g = pi_B . h  ---in other words, it's the limit of a functor from the 
category with two objects and no morphisms which maps one object to A 
and the other object to B.


The (domain-theoretic) domain product was discussed in my previous 
message to MigMit. It's a category-theoretic product in Set (among other 
categories) because the necessary morphisms exist and they satisfy the 
necessary equations. Moreover, in Set the domain product coincides with 
the cartesian product (we just forget about the orderings on the input 
domains and the resulting product). Hence, since the cartesian product 
is a category-theoretic product for Set, we know that the domain product 
must be a category-theoretic product in Set.


However, the domain product is not a category-theoretic product in 
pDCPO. First off, the objects in pDCPO are domains, but since the domain 
product of A and B has no bottom it can't be a domain, so it can't be an 
object in pDCPO. Moreover, the morphisms in pDCPO will preserve the 
domain structure--- but there's no way to do that for a map from some 
domain C to the domain product of A and B, because there's no way to map 
the bottom of C to the bottom of the domain product (because there isn't 
one!).


Conversely, the smash product is a category-theoretic product in pDCPO, 
but not in Set. Since every domain homomorphism must map bottoms to 
bottoms, it follows that f(d0) = a0 and g(d0) = b0. From this we have 
the necessary continuity to ensure that C, pi_A, and pi_B all exist in 
pDCPO. However, since there exist set-theoretic functions f and g which 
do not have that special property, the smash product is going to lose 
information about the non-bottom component of the product and so it 
cannot satisfy the necessary category-theoretic equations (in Set).




For more on the category-theoretic study of domain theory, see 
http://www.cs.bham.ac.uk/~axj/pub/papers/handy1.pdf. You can search 
the pdf for pointed dcpo to jump to the relevant sections. Of course 
there are many different category-theoretic formalizations of domain 
theory, pDCPO is just one of them. To get a survey of the terrain, you 
may want to take a look at 
http://seclab.web.cs.illinois.edu/wp-content/uploads/2011/04/Gunter85.pdf.


For a more direct introduction to domain theory and its application to 
lazy languages, see Geoffrey Burn's _Lazy Functional Languages: Abstract 
Interpretation and Compilation_.


--
Live well,
~wren

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


Re: [Haskell-cafe] Monad laws in presence of bottoms

2012-02-21 Thread Miguel Mitrofanov


22.02.2012, 09:30, wren ng thornton w...@freegeek.org:
 On 2/21/12 11:27 AM, MigMit wrote:

  Ehm... why exactly don't domain products form domains?

 One important property of domains[1] is that they have a unique bottom
 element. Given domains A and B, let us denote the domain product as:

  (A,B) def= { (a,b) | a - A, b - B }

 Which will inherit an ordering in the obvious/free way from the domain
 orderings on A and B. Since both A and B are domains, they have bottom
 elements:

  exists a0:A. forall a:A. (a0  =_A  a)
  exists b0:B. forall b:B. (b0  =_B  b)

 However, there is no free ordering on:

  { (a0,b) | b - B } \cup { (a,b0) | a - A }

What? By definition, since, a0 = a and b0 = b, we have (a0, b0) = (a0, b) 
and (a0, b0) = (a0, b0), so, (a0, b0) is clearly the bottom of A\times B.


 So all of those are minimal elements of (A,B) but none of them is a
 unique minimum; hence (A,B) is not a domain.

 The smash product gets around this because it takes all those elements
 and makes them equal, just like a strict tuple would in Haskell.

 [1] This is in the sense of domain theory. It has nothing (per se) to do
 with the many other uses of the term domain in mathematics.

Sorry, isn't the domain theory a part of mathematics?

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


Re: [Haskell-cafe] Monad laws in presence of bottoms

2012-02-21 Thread wren ng thornton

On 2/21/12 11:54 AM, Dan Doel wrote:

You don't have to get rid of bottom entirely (I think). If you make
matches against products irrefutable, then you're again in the
situation of seq being the only thing able to distinguish between _|_
and (_|_, _|_), so we could keep the current implementation (which is
efficient) without it being possible to observe within the language.
You just have to make seq not be magic on products. Miranda did this,
except it still had a seq which exposed the lie.


I thought Miranda identified _|_ with (_|_,_|_) ...though I admit I 
never really played around with Miranda.


In any case, the point is that the weirdness of Haskell's products and 
function spaces are related around this issue of eta expansion. 
Haskell's sums are also weird (they're not category-theoretic 
coproducts), but that's not clearly an issue with eta.


When it comes to practical utility, I think the choices Haskell made are 
quite nice. I'd love for smash products to have built-in syntax like 
tuples do, so I could use them cleanly rather than doing (((,) $! a) $! 
b) or defining my own ADT for them; but I understand entirely about why 
the Haskell committee decided that having two different versions of 
products/tuples would lead to API bloat and user confusion. However, 
while Haskell's choices are quite nice from a practical perspective, 
when it comes to theoretical rigor they're quite ugly. And that's the 
issue we're running into here when trying to figure out a theoretically 
sound way of defining how monads should behave with respect to bottoms.


--
Live well,
~wren

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


Re: [Haskell-cafe] Monad laws in presence of bottoms

2012-02-21 Thread wren ng thornton

On 2/22/12 1:45 AM, Miguel Mitrofanov wrote:

However, there is no free ordering on:

  { (a0,b) | b- B } \cup { (a,b0) | a- A }


What? By definition, since, a0= a and b0= b, we have (a0, b0)= (a0, b) and (a0, 
b0)= (a0, b0), so, (a0, b0) is clearly the bottom of A\times B.


Sorry, the ordering relation on domain products is defined by:

(a1,b1) =_(A,B) (a2,b2) if and only if a1 =_A a2 and b1 =_B b2



[1] This is in the sense of domain theory. It has nothing (per se) to do
with the many other uses of the term domain in mathematics.


Sorry, isn't the domain theory a part of mathematics?


Sure, domain theory is a part of mathematics, but the term domain is 
used to mean a bunch of different and largely unrelated things. For example:


* in type theory and set theory the domain of a function is the set of 
inputs on which it's defined


* in domain theory a domain is a partial order with a least element 
and the property that every non-empty countable chain has a least upper 
bound


* in ring theory a domain is is a ring which has no left nor right 
zero-divisors


* in analysis a domain is any connected open subset of a 
finite-dimensional vector space


etc.

--
Live well,
~wren

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


Re: [Haskell-cafe] Monad laws in presence of bottoms

2012-02-21 Thread Dan Doel
On Wed, Feb 22, 2012 at 1:40 AM, wren ng thornton w...@freegeek.org wrote:
 It's a category-theoretic product, but not for the category of domains. Let
 Set be the category of sets and set-theoretic functions. And let pDCPO be
 the category of (pointed) domains and their homomorphisms.

 The (domain-theoretic) domain product was discussed in my previous message
 to MigMit. It's a category-theoretic product in Set (among other categories)
 because the necessary morphisms exist and they satisfy the necessary
 equations. Moreover, in Set the domain product coincides with the cartesian
 product (we just forget about the orderings on the input domains and the
 resulting product). Hence, since the cartesian product is a
 category-theoretic product for Set, we know that the domain product must be
 a category-theoretic product in Set.

Well, like Miguel, I don't see the problem with choosing the ordering:

(a,b) = (a', b') iff a = a' and b = b'

This makes (a0, b0) the bottom element. The only difference with
Haskell's tuple types is that it lacks an extra element below (a0,
b0); it's unlifted.

It also seems to me that this _is_ the correct product for domains,
unless I'm still sketchy on what you mean by domain. I don't think it
matters that we're only considering strict homomorphisms.

 Conversely, the smash product is a category-theoretic product in pDCPO, but
 not in Set. Since every domain homomorphism must map bottoms to bottoms, it
 follows that f(d0) = a0 and g(d0) = b0. From this we have the necessary
 continuity to ensure that C, pi_A, and pi_B all exist in pDCPO. However,
 since there exist set-theoretic functions f and g which do not have that
 special property, the smash product is going to lose information about the
 non-bottom component of the product and so it cannot satisfy the necessary
 category-theoretic equations (in Set).

The smash product is not a product for domains (in general), either.
You are not allowed to throw away the components for such a product,
because given a homomorphism f that maps everything to a0, pi_B .
f,g maps everything to b0, regardless of what g is.

-- Dan

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