Re: [Haskell-cafe] Problem with own written monad

2008-01-09 Thread Paul Johnson

Michael Roth wrote:

Yes, I have done: push, pop, top, nop, count, clear, isolate and binop.
All pretty easy, once I understand that "Stack a b" thing.
  
Now you are ready to write your monad tutorial.  This is a standard rite 
of passage (or should that be "write a passage") for new Haskell 
programmers.


Paul.

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


Re: [Haskell-cafe] ANNOUNCE: Haddock version 2.0.0.0

2008-01-09 Thread Alfonso Acosta
On Jan 8, 2008 1:28 PM, David Waern <[EMAIL PROTECTED]> wrote:
> Dear Haskell community,
>
> I'm proud to announce the release of Haddock 2.0.0.0!

Great! I already tested a dracs spanshot before the release and seemed
to work well with TH code.

Any idea about when will hackage adopt this version to generate its
documentation?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

2008-01-09 Thread Cetin Sert
I'm making sure that my project files are all saved in UTF-8: I'm not newbie 
enough to miss something like that. I suspect something between Visual Studio 
and the background GHC instance that feeds it with syntax highlighting and 
environment information (like a list of functions that are accessible or 
inferred type infos etc..) might be causing a miscommunication with regards to 
the file encodings. I also tried writing -XUnicodeSyntax. I'll try to use some 
other editor and directly call the compiler to see if it works.

Thanks for all your support ^_^

Best Regards,
Cetin Sert

http://www.corsis.de

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stefan O'Rear
Sent: Mittwoch, 9. Januar 2008 23:49
To: Wolfgang Jeltsch
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function 
Names in Propositional Calculus Haskell DSL

On Wed, Jan 09, 2008 at 10:23:05PM +0100, Wolfgang Jeltsch wrote:
> Am Mittwoch, 9. Januar 2008 18:34 schrieb Cetin Sert:
> > Neither appending "{-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-}"
> 
> First, I think, you have to use -XUnicodeSyntax (as Don said), and not 
> -xunicodesyntax.  Second, -XUnicodeSyntax only enables alternative 
> notation for certain built-in syntax (as Don said).
> 
> Unicode for operators is a different matter.  I’d think, it should 
> work out of the box and wonder a bit why it doesn’t.

The give-away is that GHC gave a "UTF-8 decoding error".  This says that Cetin 
is using a different encoding, presumably (due to his mention of Visual 
Haskell, ergo Windows) UTF-16.

Stefan

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


Re: [Haskell-cafe] Show instances for error messages (Was: Refactoring status)

2008-01-09 Thread Emil Axelsson

I think partial type signatures

  http://hackage.haskell.org/trac/haskell-prime/wiki/PartialTypeAnnotations

would allow that kind of "tunneling". Is there any ongoing work on that?

/ Emil



Henning Thielemann skrev:

On Mon, 7 Jan 2008, Emil Axelsson wrote:


One approach to programming in Haskell, which I use all the time, is to write
the type signature before the function body. This means that if I'm trying to do
something strange, I will often be warned by the type checker even before I've
written the strange code.

But I've also been bitten by the problem of having to change a lot of type
signatures just because I want to e.g. show an overloaded variable.


... which is especially annoying if you need the Show instance for an
'error'.  Since 'error' denotes a programming error it should never be
evaluated and thus the Show instance is only for cases which must not
happen. Paradoxical. It would be interesting if it is possible to tunnel
Show class dictionaries through to an 'error' like IO is tunneled to
'trace'.
___
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] Comments and suggestions on code

2008-01-09 Thread Jonathan Cast

On 9 Jan 2008, at 7:57 PM, Andre Nathan wrote:


Hello

I've just found time to finish writing my first "real world"  
program, so
I thought I'd post it here and ask for insight on general issues  
such as

if there's anything that isn't done "the Haskell way", or if there's
something that could be done more efficiently.

The code is at the bottom of this message and also at
http://hpaste.org/4893. I realize it's a bit long, so if anyone could
just skim through it and see if there's anything really ugly or stupid
and point it out, it would be of great help :)

Just to make it easier to follow the code, its idea is simple:

- Build a process tree by reading entries from /proc (represented as a
  map);
- Compare each child of the init process against a whitelist (which
  comes from a configuration file);
- For each child not in the whitelist, send it a KILL signal.

The idea here is to run this on webservers and try to catch bad
customers who try to run daemons from their accounts, the typical  
script

kiddie stuff.

Anyway, there's one specific question I'd like to ask. I'm using  
"StateT

PsTree IO" to keep program state (the process tree). IO is necessary
because all information is read from /proc files. Now consider the
following function:

appendChild :: Pid -> Pid -> StateT PsTree IO Bool
appendChild ppid pid = do
  tree <- get
  let PsInfo psData children = mapLookup ppid tree
  put $ Map.insert ppid (PsInfo psData (pid:children)) tree
  return True


A return type of Bool suggests the code might fail; a constant  
function should have return type ().




It changes the program state by modifying a process tree entry, but it
does no I/O at all. The return type is there basically to match the
return type of the function which calls it (insertParent), which calls
functions that do I/O. Is there anyway to avoid the "IO" in
appendChild's signature (other than making it a pure function by  
passing

the process tree as a parameter and returning a modified map)?


This is the best solution, as well as the most idiomatic.  It's  
really simple, too:


appendChild :: Pid -> Pid -> PsTree -> PsTree
appendChild ppid pid tree = Map.insert ppid (PsInfo psData  
(pid:children)) tree

  where
PsInfo psData children = mapLookup ppid tree

Which is two lines shorter than your version, and IMHO just as clear;  
or, even better


appendChild ppid pid =
  Map.alter (fmap $ \ (PsInfo psData children) -> PsInfo psData  
(pid:children)) ppid


which is a one-liner.

Alternatively, you could keep the definition, but change the type to

appendChild :: Monad m => Pid -> Pid -> StateT PsTree m Bool

or

appendChild :: MonadState m PsTree => Pid -> Pid -> m Bool

although this is likely to be less efficient.

I would also like to try ways to improve efficiency, maybe trying a  
hash

table instead of a map for the state, and also using bytestrings. I
guess I could try making it parallel, since each child of init can be
checked independently.

Anyway, this is already longer than I thought it would be (I hope I'm
not abusing too much :)


An actual coding question, abuse?  We should be so lucky.


The code follows. Thanks in advance for any
comments or suggestions.

Andre


module Main where

import qualified Data.Map as Map


Also

import Data.Map (Map)

(Map.Map looks kind of silly).


import Directory
import Control.Monad.State
import Maybe
import System.Environment
import System.IO
import System.Posix.Files
import System.Posix.Signals
import System.Posix.Unistd
import System.Posix.User
import Text.Printf
import Text.Regex
import Text.Regex.Posix

type Pid = FilePath
type Uid = String

type PsData   = Map.Map String String
type PsChildren   = [Pid]
type KillFunction = PsTree -> Pid -> IO ()



data PsInfo = PsInfo PsData PsChildren


This sequence is better written

data PsInfo = PsInfo{
  psData :: Map String String,
  psChildren :: [Pid]
}

If find myself using typedefs relatively infrequently in Haskell.


type PsTree = Map.Map Pid PsInfo

type Whitelist = Map.Map FilePath String

mapLookup :: (Ord a) => a -> Map.Map a b -> b
mapLookup k = fromJust . Map.lookup k

-- Process Tree construction

parentPid :: PsInfo -> Pid
parentPid (PsInfo psData _) = mapLookup "PPid" psData

getProcInfo :: String -> PsData -> PsData
getProcInfo line psData = do
  case line =~~ "^([A-Za-z]+):[[:space:]]+(.*)$" of
Nothing  -> psData
Just ([_, key, value]:_) -> Map.insert key value psData



getIds :: String -> PsData -> (String, String)
getIds id psData = (rId, eId)
  where (rId:eId:_) = words (mapLookup id psData)

processData :: String -> PsData
processData procData = addIds psData
  where psData = foldr getProcInfo Map.empty (lines procData)
addIds psData = Map.union psData (idMap psData)
idMap psData = Map.fromList [("RUid", rUid), ("EUid", eUid),
 ("RGid", rGid), ("EGid", eGid)]
(rUid, eUid) = getIds "Uid" psData
(rGid, eGid) = getIds "G

[Haskell-cafe] Comments and suggestions on code

2008-01-09 Thread Andre Nathan
Hello

I've just found time to finish writing my first "real world" program, so
I thought I'd post it here and ask for insight on general issues such as
if there's anything that isn't done "the Haskell way", or if there's
something that could be done more efficiently.

The code is at the bottom of this message and also at
http://hpaste.org/4893. I realize it's a bit long, so if anyone could
just skim through it and see if there's anything really ugly or stupid
and point it out, it would be of great help :)

Just to make it easier to follow the code, its idea is simple:

- Build a process tree by reading entries from /proc (represented as a 
  map);
- Compare each child of the init process against a whitelist (which 
  comes from a configuration file);
- For each child not in the whitelist, send it a KILL signal.

The idea here is to run this on webservers and try to catch bad
customers who try to run daemons from their accounts, the typical script
kiddie stuff.

Anyway, there's one specific question I'd like to ask. I'm using "StateT
PsTree IO" to keep program state (the process tree). IO is necessary
because all information is read from /proc files. Now consider the
following function:

appendChild :: Pid -> Pid -> StateT PsTree IO Bool
appendChild ppid pid = do
  tree <- get
  let PsInfo psData children = mapLookup ppid tree
  put $ Map.insert ppid (PsInfo psData (pid:children)) tree
  return True

It changes the program state by modifying a process tree entry, but it
does no I/O at all. The return type is there basically to match the
return type of the function which calls it (insertParent), which calls
functions that do I/O. Is there anyway to avoid the "IO" in
appendChild's signature (other than making it a pure function by passing
the process tree as a parameter and returning a modified map)?

I would also like to try ways to improve efficiency, maybe trying a hash
table instead of a map for the state, and also using bytestrings. I
guess I could try making it parallel, since each child of init can be
checked independently.

Anyway, this is already longer than I thought it would be (I hope I'm
not abusing too much :) The code follows. Thanks in advance for any
comments or suggestions.

Andre


module Main where

import qualified Data.Map as Map
import Directory
import Control.Monad.State
import Maybe
import System.Environment
import System.IO
import System.Posix.Files
import System.Posix.Signals
import System.Posix.Unistd
import System.Posix.User
import Text.Printf
import Text.Regex
import Text.Regex.Posix

type Pid = FilePath
type Uid = String

type PsData   = Map.Map String String
type PsChildren   = [Pid]
type KillFunction = PsTree -> Pid -> IO ()

data PsInfo = PsInfo PsData PsChildren
type PsTree = Map.Map Pid PsInfo

type Whitelist = Map.Map FilePath String

mapLookup :: (Ord a) => a -> Map.Map a b -> b
mapLookup k = fromJust . Map.lookup k

-- Process Tree construction

parentPid :: PsInfo -> Pid
parentPid (PsInfo psData _) = mapLookup "PPid" psData
  
getProcInfo :: String -> PsData -> PsData
getProcInfo line psData = do
  case line =~~ "^([A-Za-z]+):[[:space:]]+(.*)$" of
Nothing  -> psData
Just ([_, key, value]:_) -> Map.insert key value psData 
  
getIds :: String -> PsData -> (String, String)
getIds id psData = (rId, eId)
  where (rId:eId:_) = words (mapLookup id psData)
  
processData :: String -> PsData
processData procData = addIds psData
  where psData = foldr getProcInfo Map.empty (lines procData)
addIds psData = Map.union psData (idMap psData)
idMap psData = Map.fromList [("RUid", rUid), ("EUid", eUid),
 ("RGid", rGid), ("EGid", eGid)]
(rUid, eUid) = getIds "Uid" psData
(rGid, eGid) = getIds "Gid" psData

readLink :: String -> IO String
readLink link = catch (readSymbolicLink link) (\e -> return "?")

procInfo :: Pid -> IO PsInfo
procInfo pid = do
  let dir = "/proc/" ++ pid ++ "/"
  procData <- readFile $ dir ++ "status"
  exe <- readLink $ dir ++ "exe"
  cwd <- readLink $ dir ++ "cwd"
  cmd <- readFile $ dir ++ "cmdline"
  let cmd' = subRegex (mkRegex "[^a-zA-z[:space:]\\/\\.-]") cmd " "
  info = processData procData
  adminInfo = Map.fromList [("Exe", exe), ("Cwd", cwd),
("Cmd", cmd')]
  return $ PsInfo (Map.union info adminInfo) []

addProc :: Pid -> StateT PsTree IO PsInfo
addProc pid = do
  info <- lift $ procInfo pid
  modify (Map.insert pid info)
  return info

appendChild :: Pid -> Pid -> StateT PsTree IO Bool
appendChild ppid pid = do
  tree <- get
  let PsInfo psData children = mapLookup ppid tree
  put $ Map.insert ppid (PsInfo psData (pid:children)) tree
  return True

insertParent :: Pid -> Pid -> StateT PsTree IO Bool
insertParent ppid pid = do
  tree <- get
  if Map.member ppid tree
then appendChild ppid pid
else do
  built <- insertInTree ppid
  if built
then appendChild ppid pid
else return False

inse

[Haskell-cafe] Re: Displaying # of reductions after eachcomputation in ghci?

2008-01-09 Thread Achim Schneider
"Lennart Augustsson" <[EMAIL PROTECTED]> wrote:

> What is a reduction anyway?
> 
 
() -> o -> . -> 


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

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


[Haskell-cafe] Re: ANN: A triple of new packages for talking tothe outside world

2008-01-09 Thread Achim Schneider
David Roundy <[EMAIL PROTECTED]> wrote:

> [ something that every C programmer dreams of ]
>
I'm not going to answer, I'd be just vapour-waring around.

But, yes, any-alignment any-granularity reads can be done in O(1), with
1 ranging from case to case from one instruction to a few shifts and
&'s, plus some constant cost to choose the appropriate function based
on current alignment, which could be set by things like snapToByte,
snapToWord, snapToInt128, getBit, getBits , getByte,
GetWhatever and one state var to change the "advance mode" from
request-sized to constant-sized.

As I said, I'm vapour-waring.

But then it's a swiss army knife. With many general- and
special-purpose functions.

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

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


Re: [Haskell-cafe] Re: Displaying # of reductions after eachcomputation in ghci?

2008-01-09 Thread Lennart Augustsson
What is a reduction anyway?

On Jan 8, 2008 2:48 PM, Fernando Rodriguez <[EMAIL PROTECTED]> wrote:

> Hello Stefan O'Rear,
>
> >>
> > No.
> >
> > (rambling explanation snipped awaiting further request)
> >
> > Stefan
>
> OK, I'll take the bait: why not?
>
>
>
> ___
> 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] Re: ANN: A triple of new packages for talking tothe outside world

2008-01-09 Thread Adam Langley
On Jan 9, 2008 5:01 PM, David Roundy <[EMAIL PROTECTED]> wrote:
> But I can't imagine an implementation in which this change wouldn't slow
> down getBytes for the normal case.  Perhaps the slowdown would be small,
> but it seems unwise to enforce that slowness at the API level, when we've
> already got a perfectly good API for fast binary IO.  Maybe there's some
> type hackery you could do to avoid a speed penalty, but that's a lot to add
> for a somewhat dubious benefit.

I believe that it would be an additional if statement in the fast path at least.

How about a BitGet monad which get be run in the Get monad?

> test :: Get ()
> test = do
>  runBitGet 2 (do
>getBitField 2)

So the first argument to runBitGet is the number of bytes to parse for
bit fields and then functions in BitGet can extract bit-length ints
etc.

Anyone like that idea?

AGL


-- 
Adam Langley  [EMAIL PROTECTED]
http://www.imperialviolet.org   650-283-9641
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data.Binary and serialising doubles in IEEE format

2008-01-09 Thread Adam Langley
On Jan 9, 2008 5:18 AM, allan <[EMAIL PROTECTED]> wrote:
> Essentially then, is there anyone that can write my 'putDouble' function
> or give some hint as to how I might do it.
> For the moment assume that I'm not really concerned with portability
> across platforms at least for the time being (I certainly don't think
> that the C program I'm attempting to communicate with is particularly
> portable anyway).
>

I happen to have the reverse functions lying around which might be
some help in doing this. They aren't terribly beautiful, but they'll
take an IEEE double or float from a Bytestring and return the value +
the remaining ByteString. (They aren't very well tested, but they have
been found to mostly work).

ddouble :: BS.ByteString -> (Double, BS.ByteString)
ddouble bytes = (encodeFloat fraction $ fromIntegral exp, rest) where
  fraction = sign * fromIntegral ((n .&. 0xf) .|. (if
rawExp > 0 then 0x10 else 0))
  sign = if n `shiftR` 63 == 0 then 1 else -1
  exp = rawExp - (1023 + 52)
  rawExp = (n `shiftR` 52) .&. 0x7ff
  (b, rest) = BS.splitAt 8 bytes
  n :: Word64
  n = foldl1 (.|.) $ map (\(s, v) -> (fromIntegral v) `shiftL` s) $
zip [0,8..56] $ BS.unpack b

dfloat :: BS.ByteString -> (Float, BS.ByteString)
dfloat bytes = (encodeFloat fraction $ fromIntegral exp, rest) where
  fraction = sign * fromIntegral ((n .&. 0x7f) .|. (if rawExp > 0
then 0x80 else 0))
  sign = if n `shiftR` 31 == 0 then 1 else -1
  exp = rawExp - (127 + 23)
  rawExp = (n `shiftR` 23) .&. 0xff
  (b, rest) = BS.splitAt 4 bytes
  n :: Word32
  n = foldl1 (.|.) $ map (\(s, v) -> (fromIntegral v) `shiftL` s) $
zip [0, 8, 16, 24] $ BS.unpack b


AGL

-- 
Adam Langley  [EMAIL PROTECTED]
http://www.imperialviolet.org   650-283-9641
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANN: A triple of new packages for talking tothe outside world

2008-01-09 Thread David Roundy
On Wed, Jan 09, 2008 at 11:43:52PM +0100, Achim Schneider wrote:
> "David Roundy" <[EMAIL PROTECTED]> wrote:
> 
> > On Jan 9, 2008 10:10 AM, Dominic Steinitz
> > <[EMAIL PROTECTED]> wrote:
> > > Duncan Coutts  worc.ox.ac.uk> writes:
> > > > The difficulty is in deciding what the api should be. Does it
> > > > give you a real bitstream or only a byte aligned one? If I ask
> > > > for 3 bits then 15 bytes what does it do? Does it assume I meant
> > > > 3 bits, then pad to the next byte boundary and get 15 bytes, or
> > > > does it mean get 15 bytes but at this 3 bit shift offset?
> > >
> > > I'd suggest an aligned and unaligned api.
> > >
> > > So the aligned api would get 3 bits and the 15 bytes would start
> > > from the next byte boundary.
> > >
> > > The unaligned api would get 3 bits and the 15 bytes (=15 x 8 bits)
> > > would finish still with an offset of 3.
> > 
> > Do you mean we'd have an unalignedGetBytes as well as getBytes (which
> > would remain aligned)? That would make sense, but it would seem a bit
> > heavy to duplicate all of the binary API.
> > 
> getBytes per default unaligned and additionally snapToNextByte?

But I can't imagine an implementation in which this change wouldn't slow
down getBytes for the normal case.  Perhaps the slowdown would be small,
but it seems unwise to enforce that slowness at the API level, when we've
already got a perfectly good API for fast binary IO.  Maybe there's some
type hackery you could do to avoid a speed penalty, but that's a lot to add
for a somewhat dubious benefit.

Note that you could get a similar effect with getBytes always aligned, and
an additional function shiftToByte which takes the remainder of the input
and bitshifts everything so that the current read pointer is on a byte
boundary.  Obviously this would be an O(N) operation (where N is the
remainder of the input), which could certainly be a problem.

Another option, I suppose, would be to introduce a type class for
bytewise-reading monads.  That'd be a type hack, but not such a bad one.
Then you could have the efficient implementation, and one that allows
bitwise reading, and there could also be a function that allows bitwise
parsing of a chunk of a byte-aligned data.
-- 
David Roundy
Department of Physics
Oregon State University
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Graham Fawcett
On Jan 9, 2008 6:20 PM, Don Stewart <[EMAIL PROTECTED]> wrote:
> anton:
> > Oh dear - I'm going to have to rethink the paper I was working on,
> > provisionally titled "In defense of arbitrary untracked effects in high
> > assurance software."  ;)
>
> That would be an awesome paper :)

Hear, hear!

Anton, if you're looking for a co-author, and you're willing to tackle
the high-assurance parts, I have years of experience with arbitrary
untracked effects. ;-)

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


Re: [Haskell-cafe] Tim Sweeney (the gamer)

2008-01-09 Thread J. Garrett Morris
I imagine you can get in touch with him through Epic
(www.epicgames.com) if you can't find another way to contact him.

 /g

On Jan 9, 2008 4:21 PM, Galchin Vasili <[EMAIL PROTECTED]> wrote:
> Hello,
>
>  I have been reading with great interested Tim Sweeney's slides on the
> Next Generation Programming Language. Does anybody know his email address?
>
> Kind regards, Vasili
>
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>



-- 
The man who'd introduced them didn't much like either of them, though
he acted as if he did, anxious as he was to preserve good relations at
all times. One never knew, after all, now did one now did one now did
one.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Tim Sweeney (the gamer)

2008-01-09 Thread Galchin Vasili
Hello,

 I have been reading with great interested Tim Sweeney's slides on the
Next Generation Programming Language. Does anybody know his email address?

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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Don Stewart
anton:
> Don Stewart wrote:
> >anton:
> >>OTOH, the freedom to change things on the fly can be nice to have, and 
> >>if used with "great responsibility" (mainly an understanding of what's 
> >>safe to do and what isn't), the downside can be vanishingly small.
> >
> >It can be small, unless you need to have any kind of static assurance
> >(say for high assurance software, or for new kinds of optimisations, or
> >if you want to reorder code in the compiler for parallelism).
> >
> >Then the downside to arbitrary, untracked effects in the system is huge.
> 
> Oh dear - I'm going to have to rethink the paper I was working on, 
> provisionally titled "In defense of arbitrary untracked effects in high 
> assurance software."  ;)

That would be an awesome paper :)

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


Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

2008-01-09 Thread Stefan O'Rear
On Wed, Jan 09, 2008 at 10:23:05PM +0100, Wolfgang Jeltsch wrote:
> Am Mittwoch, 9. Januar 2008 18:34 schrieb Cetin Sert:
> > Neither appending "{-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-}"
> 
> First, I think, you have to use -XUnicodeSyntax (as Don said), and 
> not -xunicodesyntax.  Second, -XUnicodeSyntax only enables alternative 
> notation for certain built-in syntax (as Don said).
> 
> Unicode for operators is a different matter.  I’d think, it should work out 
> of 
> the box and wonder a bit why it doesn’t.

The give-away is that GHC gave a "UTF-8 decoding error".  This says that
Cetin is using a different encoding, presumably (due to his mention of
Visual Haskell, ergo Windows) UTF-16.

Stefan


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


[Haskell-cafe] Re: ANN: A triple of new packages for talking tothe outside world

2008-01-09 Thread Achim Schneider
"David Roundy" <[EMAIL PROTECTED]> wrote:

> On Jan 9, 2008 10:10 AM, Dominic Steinitz
> <[EMAIL PROTECTED]> wrote:
> > Duncan Coutts  worc.ox.ac.uk> writes:
> > > The difficulty is in deciding what the api should be. Does it
> > > give you a real bitstream or only a byte aligned one? If I ask
> > > for 3 bits then 15 bytes what does it do? Does it assume I meant
> > > 3 bits, then pad to the next byte boundary and get 15 bytes, or
> > > does it mean get 15 bytes but at this 3 bit shift offset?
> >
> > I'd suggest an aligned and unaligned api.
> >
> > So the aligned api would get 3 bits and the 15 bytes would start
> > from the next byte boundary.
> >
> > The unaligned api would get 3 bits and the 15 bytes (=15 x 8 bits)
> > would finish still with an offset of 3.
> 
> Do you mean we'd have an unalignedGetBytes as well as getBytes (which
> would remain aligned)? That would make sense, but it would seem a bit
> heavy to duplicate all of the binary API.
> 
getBytes per default unaligned and additionally snapToNextByte?


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

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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Henning Thielemann

On Wed, 9 Jan 2008, David Roundy wrote:

> On Jan 9, 2008 4:21 PM, Don Stewart <[EMAIL PROTECTED]> wrote:
> > anton:
> > > OTOH, the freedom to change things on the fly can be nice to have, and
> > > if used with "great responsibility" (mainly an understanding of what's
> > > safe to do and what isn't), the downside can be vanishingly small.
> >
> > It can be small, unless you need to have any kind of static assurance
> > (say for high assurance software, or for new kinds of optimisations, or
> > if you want to reorder code in the compiler for parallelism).
> >
> > Then the downside to arbitrary, untracked effects in the system is huge.
>
> I just want to point out that unsafePerformIO is at the core of the
> (safe) bytestring library.  As SPJ et al pointed out, this is crucial
> functionality, and is only unsafe if unsafely used.

Indeed, there are hacks and they are some times necessary. The good thing
about Haskell is, that hacks look like hacks.

In Modula-3 modules using hacks must be explicitly marked as UNSAFE. See
  http://www.cs.purdue.edu/homes/hosking/m3/reference/unsafe.html
 Maybe this is also an option for Haskell?

Wouldn't this also simplify
  http://www.haskell.org/haskellwiki/Safely_running_untrusted_Haskell_code
 ?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANN: A triple of new packages for talking tothe outside world

2008-01-09 Thread David Roundy
On Jan 9, 2008 10:10 AM, Dominic Steinitz
<[EMAIL PROTECTED]> wrote:
> Duncan Coutts  worc.ox.ac.uk> writes:
> > The difficulty is in deciding what the api should be. Does it give you a
> > real bitstream or only a byte aligned one? If I ask for 3 bits then 15
> > bytes what does it do? Does it assume I meant 3 bits, then pad to the
> > next byte boundary and get 15 bytes, or does it mean get 15 bytes but at
> > this 3 bit shift offset?
>
> I'd suggest an aligned and unaligned api.
>
> So the aligned api would get 3 bits and the 15 bytes would start from the next
> byte boundary.
>
> The unaligned api would get 3 bits and the 15 bytes (=15 x 8 bits) would 
> finish
> still with an offset of 3.

Do you mean we'd have an unalignedGetBytes as well as getBytes (which
would remain aligned)? That would make sense, but it would seem a bit
heavy to duplicate all of the binary API.

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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread David Roundy
On Jan 9, 2008 4:21 PM, Don Stewart <[EMAIL PROTECTED]> wrote:
> anton:
> > OTOH, the freedom to change things on the fly can be nice to have, and
> > if used with "great responsibility" (mainly an understanding of what's
> > safe to do and what isn't), the downside can be vanishingly small.
>
> It can be small, unless you need to have any kind of static assurance
> (say for high assurance software, or for new kinds of optimisations, or
> if you want to reorder code in the compiler for parallelism).
>
> Then the downside to arbitrary, untracked effects in the system is huge.

I just want to point out that unsafePerformIO is at the core of the
(safe) bytestring library.  As SPJ et al pointed out, this is crucial
functionality, and is only unsafe if unsafely used.  (Yes, it's
unsafe, but you can write a safe module with a purely safe interface
that uses unsafePerformIO in its core.)

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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Anton van Straaten

Don Stewart wrote:

anton:
OTOH, the freedom to change things on the fly can be nice to have, and 
if used with "great responsibility" (mainly an understanding of what's 
safe to do and what isn't), the downside can be vanishingly small.


It can be small, unless you need to have any kind of static assurance
(say for high assurance software, or for new kinds of optimisations, or
if you want to reorder code in the compiler for parallelism).

Then the downside to arbitrary, untracked effects in the system is huge.


Oh dear - I'm going to have to rethink the paper I was working on, 
provisionally titled "In defense of arbitrary untracked effects in high 
assurance software."  ;)


But by "can be vanishingly small", I definitely meant something like "in 
cases where it's technically and economically appropriate".


Anton

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


RE: [Haskell-cafe] Re: GHC 6.8.2 as a library on Windows and GHCi

2008-01-09 Thread Peter Verswyvelen
> I think it is time for peter to become acquainted with the readline
> package and write a custom repl.

No no, I already did that, a long time ago, in 68000 assembly :) 

> Or just copy half of ghci into a module and call it.

I'm just interested in seeing if the interpreter/compiler/linker
infrastructure can be used as a library on both Linux/Windows/OSX, and for
creating plugins at runtime. When using Microsoft's C#/.NET I used that a
lot. On that platform it is very easy to generate code on the fly, call the
C# compiler, emit code, load code, creating "plugins". But Microsoft.NET
does not support Haskell :( F# is a good step forward, but it's not lazy,
and I am.




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


Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

2008-01-09 Thread Wolfgang Jeltsch
Am Mittwoch, 9. Januar 2008 18:24 schrieb Felipe Lessa:
> […]

> But for the others, what is wrong with e.g. (\/), (/\), (-->) and (<->)?

These are not the true symbols.  They look ugly compared to the real ones.  
Nice typography is a great thing!

> You could write things like 'a /\ b --> c'.

With Cetin’s approach you could write things like “a ∧ b → c”.  Doesn’t this 
look a lot better? :-) 

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


Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

2008-01-09 Thread Wolfgang Jeltsch
Am Mittwoch, 9. Januar 2008 18:34 schrieb Cetin Sert:
> Neither appending "{-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-}"

First, I think, you have to use -XUnicodeSyntax (as Don said), and 
not -xunicodesyntax.  Second, -XUnicodeSyntax only enables alternative 
notation for certain built-in syntax (as Don said).

Unicode for operators is a different matter.  I’d think, it should work out of 
the box and wonder a bit why it doesn’t.

> […]

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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Don Stewart
anton:
> OTOH, the freedom to change things on the fly can be nice to have, and 
> if used with "great responsibility" (mainly an understanding of what's 
> safe to do and what isn't), the downside can be vanishingly small.

It can be small, unless you need to have any kind of static assurance
(say for high assurance software, or for new kinds of optimisations, or
if you want to reorder code in the compiler for parallelism).

Then the downside to arbitrary, untracked effects in the system is huge.

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


[Haskell-cafe] Re: Difference lists and ShowS

2008-01-09 Thread apfelmus

Albert Y. C. Lai wrote:

apfelmus wrote:
I don't know a formalism for easy reasoning about time in a lazy 
language. Anyone any pointers? Note that the problem is already 
present for difference lists in strict languages.


http://homepages.inf.ed.ac.uk/wadler/topics/strictness-analysis.html

especially "strictness analysis aids time analysis".


Ah, of course, thanks. Together with

  D. Sands. Complexity Analysis for a Lazy Higher-Order Language.
  http://citeseer.ist.psu.edu/291589.html

for the higher-order case, a satisfactory analysis can be put together.


The formalism is basically as follows: for a function f, let f^T denote 
the time needed to execute it to weak normal form given that it's 
arguments are already in weak normal form. Weak normal form = full 
normal form for algebraic values and lambda-abstraction for functions = 
what you'd expect in a strict language. Plain values = nullary 
functions. For instance


  (++)^T [] ys = 1 + ys^T = 1
  (++)^T (x:xs) ys = 1 + (x:(xs ++ ys))^T
   = 1 + (++)^T xs ys + xs^T + ys^T  -- (:) is free
   = 1 + (++)^T xs ys
 ==>
  (++)^T xs ys = O(length xs)

Substituting a function application by the function body is counted as 1 
time step, that's where the  1 +  comes from.



For difference lists, we have

  (.)^T f g = O(1)

since it immediately returns the lambda-abstraction  \x -> f(g x) . Now, 
we missed something important about difference lists namely the function


  toList f = f []

that turns a difference list into an ordinary list and this function is 
O(n). In contrast, The "pendant" for ordinary lists, i.e. the identity 
function, is only O(1). Why is it O(n)? Well, (.) itself may be O(1) but 
it constructs a function that needs lots of time to run. In particular


  (f . g)^T [] = ((\x->f (g x))[])^T
   = 1 + (f (g []))^T
   = 1 + f^T (g []) + (g [])^T
   = 1 + f^T (g []) + g^T []

So, to analyze higher-order functions, we simply have to keep track of 
the "size" of the returned functions (more precisely, Sands uses 
"cost-closures"). The above reduces to


  (f . g)^T [] = 1 + f^T [] + g^T []

Since our difference lists don't care of what they are prepended to

  f^T xs = f^T []

Cheating a bit with the notation, we can write

  toList^T (f . g) = 1 + toList^T f + toList^T g

This means that a difference list build out of  n  elements by  m 
applications of (.) will take  O(n + m) time. This is the same as O(m) 
because m >= n , our lists are concatenations of singletons. That's not 
O(n) as anticipated, but it's alright: a concatenation of  m  empty 
lists is empty but clearly takes O(m) time, so the number of 
concatenations matters.



Since difference lists offer such a good concatenation, why not replace 
ordinary lists entirely? Well, the problem is that we have another 
function that should run fast, namely  head . For ordinary lists,


  head^T xs = O(1)

but for difference lists, we have

  (head . toList)^T f = O(m) which is >= O(n)

in the worst case, lazy evaluation notwithstanding. How to analyze lazy 
evaluation? Wadler's approach is to add an extra argument to every 
expression which says how much of the expression is to be evaluated. 
This extra information can be encoded via projections. But I think it's 
sufficient here to let (head expr)^T symbolize the time to reduce  expr 
 to weak head normal form. For example,


  (head . toList)^T (f . g) = 1 + (head . toList)^T f

assuming that  f  is nonempty. But due to the  1 + , any left-nested 
composition like


  head . toList $ (((a . b) . c) . d) . e

still needs O(m) time. So, difference lists are no "eierlegende 
wollmilchsau" either.




Regards,
apfelmus

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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Anton van Straaten

Peter Verswyvelen wrote:
But I'm amazed that impure (albeit strong) languages like LISP and 
Scheme are still used for projects... I mean, in Scheme you can "set!" 
the addition operator to become a multiplication operator at runtime, 
modifying global behavior... Now that's a side effect, C/C++ is nothing 
compared to that! So I guess that with such great power comes great 
responsibility?


Scheme and Lisp typically constrain this feature in various ways, 
ranging from compiler options and declarations to, more recently, 
features of a module system.


For example, in R6RS Scheme, variables and syntax imported via the 
module system cannot be mutated, so the denotation of a name (including 
names like "+") can be statically determined.


OTOH, the freedom to change things on the fly can be nice to have, and 
if used with "great responsibility" (mainly an understanding of what's 
safe to do and what isn't), the downside can be vanishingly small.


Anton

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


Re: [Haskell-cafe] GHC 6.8.2 as a library on Windows and GHCi

2008-01-09 Thread Austin Seipp
Excerpts from Peter Verswyvelen's message of Wed Jan 09 10:07:46 -0600 2008:
> Is my code incorrect, or is this a (known?) bug in GHC 6.8.2 on Windows? 
> I haven't tried the Linux version yet.

The same thing happens on my Windows XP box as it does with yours. On
both windows and my linux box, ghc --make works fine, and on linux with
ghci,  it works fine but not on windows (and fails with the exact same
error.)

Just from a general idea I would say that the reason would be related
to the linker loading base twice: once when ghci itself is started, and
the second time when you actually call into the ghc api;
setSessionDynFlags will give your session knowledge of all installed
packages, so when you're actually executing code using runStmt it may 
reload the object file into an address space where it already resides.
GHCi only has one symbol table in its address space, so loading twice
will naturally cause clashes.

This seems slightly related to the fact that, you can't do similar with
hs-plugins as it directly interfaces with the runtime linker and
therefore you must always compile your apps that use hs-plugins rather
than loading them into ghci.

Why this would only occur on Windows and not linux though, I have no 
idea. It seems a bug report is well in order.

I'm probably just talking nonsense though; I guess you'll just have to
make due with ghc --make! Sorry I couldn't further help, you may get
more info by asking a ghc guru.

- Austin

-- 
"It was in the days of the rains that their prayers went up, 
not from the fingering of knotted prayer cords or the spinning 
of prayer wheels, but from the great pray-machine in the
monastery of Ratri, goddess of the Night."
 Roger Zelazny
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: GHC 6.8.2 as a library on Windows and GHCi

2008-01-09 Thread Achim Schneider
"Attila Babo" <[EMAIL PROTECTED]> wrote:

> Using ghci your code is fine under Linux, but fails on Windows, even
> with a daily snapshot from today. It's OK when compiling with ghc on
> both platforms.
>
I think it is time for peter to become acquainted with the readline
package and write a custom repl.

Or just copy half of ghci into a module and call it.

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

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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Peter Verswyvelen

Derek Elkins wrote:
> A shorter and lighter and and also interesting and entertaining read is:
> 
http://research.microsoft.com/~simonpj/Papers/haskell-retrospective/index.htm


Just read it, quoting:

`Tony Hoare’s comment: “I fear that Haskell is doomed to succeed”`

LOL! Very good stuff

If Haskell wasn't pure, I would not spent so much time trying to bend my 
over-imperative mind to it. I had it with impure languages, way to 
tricky. Those languages were nice when I was young & reckless :)


But I'm amazed that impure (albeit strong) languages like LISP and 
Scheme are still used for projects... I mean, in Scheme you can "set!" 
the addition operator to become a multiplication operator at runtime, 
modifying global behavior... Now that's a side effect, C/C++ is nothing 
compared to that! So I guess that with such great power comes great 
responsibility?


Peter





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


Re: [Haskell-cafe] GHC 6.8.2 as a library on Windows and GHCi

2008-01-09 Thread Attila Babo
Using ghci your code is fine under Linux, but fails on Windows, even
with a daily snapshot from today. It's OK when compiling with ghc on
both platforms.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Trouble with function with two clauses

2008-01-09 Thread Henning Thielemann

On Wed, 9 Jan 2008, Fernando Rodriguez wrote:

> I have the following type and function:
>
> data ConsCell a = Nil | Cons a (ConsCell a) deriving Show
> head' Nil = Nothing
> head' (Cons a _) = Just a
>
> Works fine, however, what's wrong with the following function?
>
> head''
>   | Nil = Nothing
>   | Cons a _ = Just a

Maybe you want

head''' x =
   case x of
  Nil  -> Nothing
  Cons a _ -> Just a
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: US Homeland Security program language security risks

2008-01-09 Thread Seth Gordon

Daniel Fischer wrote:

Am Sonntag, 6. Januar 2008 15:54 schrieb Achim Schneider:

That's an interesting task: Design a non-touring complete,
restricted language in which every expression is decidable, without
making the language unusable for usual programming problems.


I'm not a logician, but didn't Gödel prove that you couldn't express the 
(full) arithmetic of natural numbers in such a language?


What if you restricted yourself to the arithmetic of natural numbers 
modulo 2^64?

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


Re: [Haskell-cafe] Trouble with function with two clauses

2008-01-09 Thread gwern0
On 2008.01.09 18:15:33 +, Fernando Rodriguez <[EMAIL PROTECTED]> scribbled 
0.3K characters:
>
> Hi,
>
> I have the following type and function:
>
> data ConsCell a = Nil | Cons a (ConsCell a) deriving Show
> head' Nil = Nothing
> head' (Cons a _) = Just a
>
> Works fine, however, what's wrong with the following function?
>
> head''| Nil = Nothing
>   | Cons a _ = Just a
>
> Thanks!

Couple of things. Your head'' is trying to use pattern-matching, but guards 
(which are what you are actually using) require a Bool expression on the left 
hand side; guards just desugar into if-then-else clauses.

In this case it'd look something like

> head'' a = if Nil then Nothing else if Cons a _ then Just a else ???

This doesn't make sense. Nil is just Nil, it's not in Bool; the if can't do 
anything with that. Similarly, Cons a _ is just ConsCell and in the Show 
typeclass; it too is not Bool.

If we turn it into pattern-matching:

> head'' Nil = Nothing
> head'' Cons a _ = Just a

But this still doesn't work - one definition takes a single argument, and the 
other 3; Nil (1), vs [Cons, a, _] (3). So:

head'' Nil = Nothing
head'' (Cons a _) = Just a

Parentheses force the Cons to be seen as a single argument.

So I guess your final product would look like this, which is pretty much what 
you start out with.

> data ConsCell a = Nil | Cons a (ConsCell a) deriving Show
>
> head' :: ConsCell a -> Maybe a
> head' Nil = Nothing
> head' (Cons a _) = Just a

--
gwern
Hackers Emerson EO SAS Majic CANSLO rail ABC CFD RSOC


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


Re: [Haskell-cafe] Trouble with function with two clauses

2008-01-09 Thread Tillmann Rendel

Fernando Rodriguez wrote:

data ConsCell a = Nil | Cons a (ConsCell a) deriving Show
head' Nil = Nothing
head' (Cons a _) = Just a

Works fine, however, what's wrong with the following function?

head'' | Nil = Nothing
| Cons a _ = Just a


You cannot use | as a general shortcut in function definitions as you 
try here. The stroke is instead used to express different branches 
selected by boolean expressions:


  headIfNotZero Nil = Nothing
  headIfNotZero (Cons a)
| a == 0= Nothing
| otherwise = Just a

In this definition, (a == 0) and (otherwise) are boolean expressions.

  GHCi, version 6.8.1: http://www.haskell.org/ghc/  :? for help
  Loading package base ... linking ... done.
  Prelude> otherwise
  True

But in your definition of head'', Nil and (Cons a) are Patterns, not 
boolean expressions, so it doesnt work out. If you don't like to write 
out the name of the function you want to define over and over again, you 
can use an explicit case statement:


  head''' x = case x of
Nil  -> Nothing
Cons a _ -> Just a

This is sometimes easier to read, but in this case, I would use your 
head' definition.


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


Re: [Haskell-cafe] Trouble with function with two clauses

2008-01-09 Thread Fraser Wilson
In head'', what is being compared to Nil?

The guards of a function are a series of Boolean expressions; but in your
example they are of type ConsCell a.  The difference is that in a pattern,
the structure of the argument is matched; in a guard, an arbitrary
expression is evaluated.

I have always found the Haskell report instructive in these cases;
particularly the transformations into the core language -- in this case see
section 4.4.3.2 (http://haskell.org/onlinereport/decls.html#sect4.4.3.2);
this should make it clear why head'' is not valid Haskell.

cheers,
Fraser.

Guards are really a series of Boolean equations, and the first that
evaluates to true
On Jan 9, 2008 7:15 PM, Fernando Rodriguez < [EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I have the following type and function:
>
> data ConsCell a = Nil | Cons a (ConsCell a) deriving Show
> head' Nil = Nothing
> head' (Cons a _) = Just a
>
> Works fine, however, what's wrong with the following function?
>
> head''
>| Nil = Nothing
>| Cons a _ = Just a
>
> Thanks!
>
>
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Silly question: accessing a slot in a data type

2008-01-09 Thread Fernando Rodriguez

Hello Miguel,


Also, how do I represent an AddressBook with an empty list and one
with data on its list for my pattern matching?


phoneLookup (AddressBook []) = Nothing


Thanks.



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


[Haskell-cafe] Trouble with function with two clauses

2008-01-09 Thread Fernando Rodriguez


Hi,

I have the following type and function:

data ConsCell a = Nil | Cons a (ConsCell a) deriving Show
head' Nil = Nothing
head' (Cons a _) = Just a

Works fine, however, what's wrong with the following function?

head'' 
	| Nil = Nothing

| Cons a _ = Just a

Thanks!



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


Re: [Haskell-cafe] Silly question: accessing a slot in a data type

2008-01-09 Thread Miguel Mitrofanov
Also, how do I represent an AddressBook with an empty list and one  
with data on its list for my pattern matching?


phoneLookup (AddressBook []) = Nothing
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Derek Elkins
On Wed, 2008-01-09 at 15:06 +, Dougal Stanton wrote:
> On 09/01/2008, Yu-Teh Shen <[EMAIL PROTECTED]> wrote:
> > I got question about why haskell insist to be a purely FL. I mean is
> > there any feature which is only support by pure?
> 
> Have a look at the ueber-retrospective on Haskell, fifty-five pages of
> all the history and motivation one could possibly want.
> 
> 
> 
> It's interesting reading, I promise! ;-)

A shorter and lighter and and also interesting and entertaining read is:
http://research.microsoft.com/~simonpj/Papers/haskell-retrospective/index.htm

While the reason Haskell was pure was to support laziness, at this point
though it's safe to say Haskell "insists" on being pure no more than
water "insists" on being wet.

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


RE: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

2008-01-09 Thread Cetin Sert
Neither appending "{-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-}" at the 
beginning of a .hs source file in Visual Haskell nor setting the ghc options 
from the project properties seems to solve the problem. I keep getting "Error   
 1   lexical error (UTF-8 decoding error)
C:\Users\Sert\Lab\Haskell\HaskellApp1\HaskellApp1\src\Explogic.hs   Line 25 
Column 2" in the IDE. Maybe this is Visual Haskell-specific o_O!?

-- not
(¬) :: P a => a -> Bool
(¬) a | g a   = False
  | otherwise = True


Best Regards,
Cetin Sert


-Original Message-
From: Don Stewart [mailto:[EMAIL PROTECTED] 
Sent: Mittwoch, 9. Januar 2008 18:24
To: Cetin Sert
Cc: Haskell-Cafe@haskell.org
Subject: Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function 
Names in Propositional Calculus Haskell DSL

cetin.sert:
>I want to design a DSL in Haskell for propositional calculus. But instead
>of using natural language names for functions like or, and, implies etc. I
>want to use Unicode symbols as infix functions NOT,  *, *, ->, <-> But I
>keep getting error messages from the GHC parser. Is there a way to make
>GHC parse my source files correctly? If it is not possible yet, please
>consider this as a "feature request".
> 
>
> 

The "survey of Haskell unicode support" might have some advice,

http://blog.kfish.org/2007/10/survey-haskell-unicode-support.html

See also -XUnicodeSyntax for enabling unicode keywords for -> <- forall
et al.

This is turning into an FAQ, so clarifying the unicode support in the
GHC user's guide would be a good result.

-- Don

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


Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

2008-01-09 Thread Tristan Allwood
Hi,

Attached works fine for me (ghc 6.8.2)

You'll have trouble with → though, as ghc steals that symbol for type
signature declarations.  

A ghc expert could probably shed more light;

Cheers,

Tris

GHCi also doesn't (at least for me) print symbol names correctly, but
that's a different issue.

>ghci Bloop.hs 
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( Bloop.hs, interpreted )
Ok, modules loaded: Main.
*Main> :browse
(�) :: Bool -> Bool
(� :: Bool -> Bool -> Bool
(� :: Bool -> Bool -> Bool
(�) :: Bool -> Bool -> Bool
*Main> False ˅ True
True



On Wed, Jan 09, 2008 at 06:17:13PM +0100, Cetin Sert wrote:
> I want to design a DSL in Haskell for propositional calculus. But instead of 
> using natural language names for functions like or, and, implies etc. I want 
> to use Unicode symbols as infix functions ¬, ˅, ˄, →, ↔ But I keep getting 
> error messages from the GHC parser. Is there a way to make GHC parse my 
> source files correctly? If it is not possible yet, please consider this as a 
> “feature request”.
> 
>  
> 
> Best Regards,
> 
> Cetin Sert
> 
> INF 521, 4-6-2
> 
> 69120 Heidelberg
> 
> Germany
> 
>  
> 
> http://www.corsis.de
> 

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


-- 
Tristan Allwood
PhD Student
Department of Computing
Imperial College London
{-# OPTIONS_GHC -fglasgow-exts #-}

( ¬ ) :: Bool → Bool
( ¬ ) = not

(˅) :: Bool → Bool → Bool
(˅) = (||)

(˄) :: Bool → Bool → Bool
(˄) = (&&)

(↔) :: Bool → Bool → Bool
(↔) = (==)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

2008-01-09 Thread Felipe Lessa
On Jan 9, 2008 3:17 PM, Cetin Sert <[EMAIL PROTECTED]> wrote:
> I want to design a DSL in Haskell for propositional calculus. But instead of
> using natural language names for functions like or, and, implies etc. I want
> to use Unicode symbols as infix functions ¬, ˅, ˄, →, ↔

I guess you can't do anything for ¬, as it is a prefix function. But
for the others, what is wrong with e.g. (\/), (/\), (-->) and (<->)?
You could write things like 'a /\ b --> c'.

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


Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

2008-01-09 Thread Don Stewart
cetin.sert:
>I want to design a DSL in Haskell for propositional calculus. But instead
>of using natural language names for functions like or, and, implies etc. I
>want to use Unicode symbols as infix functions NOT,  *, *, ->, <-> But I
>keep getting error messages from the GHC parser. Is there a way to make
>GHC parse my source files correctly? If it is not possible yet, please
>consider this as a "feature request".
> 
>
> 

The "survey of Haskell unicode support" might have some advice,

http://blog.kfish.org/2007/10/survey-haskell-unicode-support.html

See also -XUnicodeSyntax for enabling unicode keywords for -> <- forall
et al.

This is turning into an FAQ, so clarifying the unicode support in the
GHC user's guide would be a good result.

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


[Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

2008-01-09 Thread Cetin Sert
I want to design a DSL in Haskell for propositional calculus. But instead of 
using natural language names for functions like or, and, implies etc. I want to 
use Unicode symbols as infix functions ¬, ˅, ˄, →, ↔ But I keep getting error 
messages from the GHC parser. Is there a way to make GHC parse my source files 
correctly? If it is not possible yet, please consider this as a “feature 
request”.

 

Best Regards,

Cetin Sert

INF 521, 4-6-2

69120 Heidelberg

Germany

 

http://www.corsis.de

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


Re: [Haskell-cafe] GHC 6.8.2 as a library on Windows and GHCi

2008-01-09 Thread Peter Verswyvelen

[EMAIL PROTECTED] wrote:

I think your installation is just buggy. I ran it here, and it compiles fine (although it doesn't run, as 
Linux obviously has "d:/app/ghc-6.8.2") and runs, printing "4" if I replace the string 
with "/usr/lib/ghc-6.8.2". Could it be that your GHCi is not the 6.8.2 one, or your path incorrect?
  
Interesting... But I don't see what could be wrong with my installation. 
I just downloaded and installed the binary installer from the Internet. 
I did have to expose the package ghc before GHCi could compile my code.


I also just tried a clean install of GHC-6.8.2 on a brand new Windows XP 
SP2 system (that never had any GHC nor GCC nor MINGW installed before), 
but that also gives the same error.


So I guess it runs fine on Linux (as you tested), but not on Windows?

Thanks,
Peter



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


Re: [Haskell-cafe] US Homeland Security program language security risks

2008-01-09 Thread Isaac Dupree

Bryan O'Sullivan wrote:

Yitzchak Gale wrote:


Perhaps Coverity's interest could be
piqued if they were made aware of Haskell's emergence
as an important platform in security-sensitive
industries such as finance and chip design, and of
the significant influence that Haskell is having on the
design of all other major programming languages.


During one of Simon PJ's tutorials at OSCON last year, a Coverity
engineer was in the audience.  He told us afterwards that he downloaded
the GHC source and gave a try at analysing it while Simon talked.  He
didn't get far, of course; their software wasn't built for the tricks
that -fvia-C plays.  But they have at least one person who was that
interested.


unregisterised, it should be standard C without tricks, though still 
nothing like ordinary C and therefore possibly not analyzable


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


[Haskell-cafe] Re: [Haskell] ANNOUNCE: Haddock version 2.0.0.0

2008-01-09 Thread Felipe Lessa
Now I see. Thanks David and Simon for the clarifications! =)

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


Re: [Haskell-cafe] GHC 6.8.2 as a library on Windows and GHCi

2008-01-09 Thread gwern0
On 2008.01.09 17:07:46 +0100, Peter Verswyvelen <[EMAIL PROTECTED]> scribbled 
4.7K characters:
>I while I ago I sent an email regarding hs-plugins not working on windows.
>
>I now tried to directly use GHC API, but I also failed.
>
>The following program (which might be buggy, I copy/pasted from various
>sources)
>
>import DynFlags
>import GHC
>
>main = defaultErrorHandler defaultDynFlags $ do
>  session <- newSession (Just "d:/app/ghc-6.8.2")
>  flags <- getSessionDynFlags session
>  (flags, _) <- parseDynamicFlags flags []
>  GHC.defaultCleanupHandler flags $ do
>setSessionDynFlags session flags{ hscTarget=HscInterpreted }
>prelude <- findModule session (mkModuleName "Prelude") Nothing
>setContext session [] [prelude]
>runStmt session "let n = 2 + 2" RunToCompletion -- n is bound
>runStmt session "n"  RunToCompletion-- 4 is printed (note
>"it" is bound)
>
>gives the following error when run from GHCi
>*Main> :load "l:/test.hs"
>[1 of 1] Compiling Main ( l:/test.hs, interpreted )
>Ok, modules loaded: Main.
>*Main> main
>
>GHCi runtime linker: fatal error: I found a duplicate definition for
>symbol
>   _forkOS_entry
>whilst processing object file
>   d:/app/ghc-6.8.2/lib\base-3.0.1.0/HSbase-3.0.1.0.o
>This could be caused by:
>   * Loading two different object files which export the same symbol
>   * Specifying the same object file twice on the GHCi command line
>   * An incorrect `package.conf' entry, causing some object to be
> loaded twice.
>GHCi cannot safely continue in this situation.  Exiting now.  Sorry.
>
>Process haskell finished
>
>Is my code incorrect, or is this a (known?) bug in GHC 6.8.2 on Windows? I
>haven't tried the Linux version yet.
>
>NOTE: The program *does* run fine when compiling via GHC --make.
>
>Thanks,
>Peter

I think your installation is just buggy. I ran it here, and it compiles fine 
(although it doesn't run, as Linux obviously has "d:/app/ghc-6.8.2") and runs, 
printing "4" if I replace the string with "/usr/lib/ghc-6.8.2". Could it be 
that your GHCi is not the 6.8.2 one, or your path incorrect?

--
gwern
& b AHPCRC Playboy Dolch += SG530 Karimov CNCIS beef


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


[Haskell-cafe] GHC 6.8.2 as a library on Windows and GHCi

2008-01-09 Thread Peter Verswyvelen

I while I ago I sent an email regarding hs-plugins not working on windows.

I now tried to directly use GHC API, but I also failed.

The following program (which might be buggy, I copy/pasted from various 
sources)


import DynFlags
import GHC

main = defaultErrorHandler defaultDynFlags $ do
 session <- newSession (Just "d:/app/ghc-6.8.2")
 flags <- getSessionDynFlags session
 (flags, _) <- parseDynamicFlags flags []
 GHC.defaultCleanupHandler flags $ do
   setSessionDynFlags session flags{ hscTarget=HscInterpreted }
   prelude <- findModule session (mkModuleName "Prelude") Nothing
   setContext session [] [prelude]
   runStmt session "let n = 2 + 2" RunToCompletion -- n is bound
   runStmt session "n"  RunToCompletion-- 4 is printed 
(note "it" is bound)



gives the following error when run from GHCi

*Main> :load "l:/test.hs"
[1 of 1] Compiling Main ( l:/test.hs, interpreted )
Ok, modules loaded: Main.
*Main> main

GHCi runtime linker: fatal error: I found a duplicate definition for symbol
  _forkOS_entry
whilst processing object file
  d:/app/ghc-6.8.2/lib\base-3.0.1.0/HSbase-3.0.1.0.o
This could be caused by:
  * Loading two different object files which export the same symbol
  * Specifying the same object file twice on the GHCi command line
  * An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation.  Exiting now.  Sorry.


Process haskell finished

Is my code incorrect, or is this a (known?) bug in GHC 6.8.2 on Windows? 
I haven't tried the Linux version yet.


NOTE: The program *does* run fine when compiling via GHC --make.

Thanks,
Peter


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


Re: [Haskell-cafe] US Homeland Security program language security risks

2008-01-09 Thread Bryan O'Sullivan
Yitzchak Gale wrote:

> Perhaps Coverity's interest could be
> piqued if they were made aware of Haskell's emergence
> as an important platform in security-sensitive
> industries such as finance and chip design, and of
> the significant influence that Haskell is having on the
> design of all other major programming languages.

During one of Simon PJ's tutorials at OSCON last year, a Coverity
engineer was in the audience.  He told us afterwards that he downloaded
the GHC source and gave a try at analysing it while Simon talked.  He
didn't get far, of course; their software wasn't built for the tricks
that -fvia-C plays.  But they have at least one person who was that
interested.

However, it would cost several million dollars to produce a tool as
slick as Coverity's for Haskell (Prevent is really very impressive).
That would rival Coverity's R&D expenditure to date; they're a small
company.  I'd have a hard time believing that any such investment could
be recouped through commercial sales within the next decade.

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


[Haskell-cafe] Re: Silly question: accessing a slot in a data type

2008-01-09 Thread Achim Schneider
Fernando Rodriguez <[EMAIL PROTECTED]> wrote:

> 
> Hi,
> 
> I'm writing a very simple address book. I defined the follwoing types
> for Contact and AddressBook:
> 
> type Name= String
> type PhoneNumber= Integer
> 
> data Contact = Contact {name :: Name, phone:: PhoneNumber} deriving
> Show
> 
> -- The addressBook is a lista of Contacts
> data AddressBook= AddressBook [Contact] deriving Show
> 
> -- Create a test one
> ag = Agenda [Contact "BillG" 618965332, Contact "Linus" 5897458]
> 
> I wan't to write a function to search for a given phone by name and
> return a Maybe PhoneNumber.  I know how to do this recursively on a
> "raw" list, but how do I access the list inside AddressBook? Also,
> how do I represent an AddressBook with an empty list and one with
> data on its list for my pattern matching?
> 
> Thanks!

Sorry, I meant to write something along the lines of

bookHead :: AddressBook -> Contact
bookHead (AddressBook (c:cs)) = c

which isn't really useful.

I think you want to say

type AdressBook = [Contact]

instead.

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

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


[Haskell-cafe] Re: Silly question: accessing a slot in a data type

2008-01-09 Thread Achim Schneider
Fernando Rodriguez <[EMAIL PROTECTED]> wrote:

> 
> Hi,
> 
> I'm writing a very simple address book. I defined the follwoing types
> for Contact and AddressBook:
> 
> type Name= String
> type PhoneNumber= Integer
> 
> data Contact = Contact {name :: Name, phone:: PhoneNumber} deriving
> Show
> 
> -- The addressBook is a lista of Contacts
> data AddressBook= AddressBook [Contact] deriving Show
> 
> -- Create a test one
> ag = Agenda [Contact "BillG" 618965332, Contact "Linus" 5897458]
> 
> I wan't to write a function to search for a given phone by name and
> return a Maybe PhoneNumber.  I know how to do this recursively on a
> "raw" list, but how do I access the list inside AddressBook? Also,
> how do I represent an AddressBook with an empty list and one with
> data on its list for my pattern matching?
> 
> Thanks!

like this:

manglePhone contact = contact { phone = ( 1 + phone contact ) }

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

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


[Haskell-cafe] Silly question: accessing a slot in a data type

2008-01-09 Thread Fernando Rodriguez


Hi,

I'm writing a very simple address book. I defined the follwoing types for 
Contact and AddressBook:


type Name= String
type PhoneNumber= Integer

data Contact = Contact {name :: Name, phone:: PhoneNumber} deriving Show

-- The addressBook is a lista of Contacts
data AddressBook= AddressBook [Contact] deriving Show

-- Create a test one
ag = Agenda [Contact "BillG" 618965332, Contact "Linus" 5897458]

I wan't to write a function to search for a given phone by name and return 
a Maybe PhoneNumber.  I know how to do this recursively on a "raw" list, 
but how do I access the list inside AddressBook? Also, how do I represent 
an AddressBook with an empty list and one with data on its list for my pattern 
matching?


Thanks!



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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Mattias Bengtsson
On Wed, 2008-01-09 at 15:06 +, Dougal Stanton wrote:
> Have a look at the ueber-retrospective on Haskell, fifty-five pages of
> all the history and motivation one could possibly want.
> 
> 
> 
> It's interesting reading, I promise! ;-)

I actually think it was a really interesting read when i read it a year
ago or so! :)

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


[Haskell-cafe] Re: ANN: A triple of new packages for talking tothe outside world

2008-01-09 Thread Dominic Steinitz
Duncan Coutts  worc.ox.ac.uk> writes:

> 
> 
> On Wed, 2008-01-09 at 09:26 +, Dominic Steinitz wrote:
> > Adam Langley  imperialviolet.org> writes:
> > 
> > > But if this is useful to you, make any requests. I'll (hopefully) do
> > > them, clean it up and push a new release of binary-strict.
> > > 
> > How difficult would it be to have a getBits functions as well as a getBytes?
> > That would allow me drop the dependency on NewBinary in the ASN.1 package.
> 
> The difficulty is in deciding what the api should be. Does it give you a
> real bitstream or only a byte aligned one? If I ask for 3 bits then 15
> bytes what does it do? Does it assume I meant 3 bits, then pad to the
> next byte boundary and get 15 bytes, or does it mean get 15 bytes but at
> this 3 bit shift offset?
> 
> Duncan
> 

I'd suggest an aligned and unaligned api. 

So the aligned api would get 3 bits and the 15 bytes would start from the next
byte boundary.

The unaligned api would get 3 bits and the 15 bytes (=15 x 8 bits) would finish
still with an offset of 3.

Dominic.


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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Dougal Stanton
On 09/01/2008, Yu-Teh Shen <[EMAIL PROTECTED]> wrote:
> I got question about why haskell insist to be a purely FL. I mean is
> there any feature which is only support by pure?

Have a look at the ueber-retrospective on Haskell, fifty-five pages of
all the history and motivation one could possibly want.



It's interesting reading, I promise! ;-)

D.
-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Why purely in haskell?

2008-01-09 Thread Achim Schneider
"Yu-Teh Shen" <[EMAIL PROTECTED]> wrote:

> I got question about why haskell insist to be a purely FL. I mean is
> there any feature which is only support by pure?
> I mean maybe the program is much easier to prove? Or maybe we can
> cache some value for laziness.
> Could anyone give me some more information about why haskell needs to
> be  pure.
> 
To give a short answer: Because if pureness would be abandoned for easy
implementation of feature X, features Y and Z would become completely
awkward. 

The pureness is an ideological design decision basing on the
assumption that pureness is ideal to ensure whole-system consistency.

Most important is referential transparency, its lack of spooky
side-effects and thus making global memoization of evaluation results
feasible.

In fact, the most obvious point really seems to be that

getChar :: Char
cant' be cached, though its type implies it,

while
getChar :: IO Char
enshures that only the _action_ of getting a char can be cached, not the
char itself. (and asking why and how the IO type does that opens a big
can of worms)

It's along the lines of "a value is an unary, static function that
returns a value" vs. "an input function is an unary, dynamic function
that returns a value" and the proper handling of the terms "static" and
"dynamic" in every possible case.

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

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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Neil Mitchell
Hi Shen,

> I got question about why haskell insist to be a purely FL. I mean is
> there any feature which is only support by pure?

Laziness. It is very difficult to have a lazy language which is not pure.

Laziness and purity together help with equational reasoning, compiler
transformations, less obscure bugs, better compositionality etc.

Thanks

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


[Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Yu-Teh Shen
I got question about why haskell insist to be a purely FL. I mean is
there any feature which is only support by pure?
I mean maybe the program is much easier to prove? Or maybe we can
cache some value for laziness.
Could anyone give me some more information about why haskell needs to be  pure.

Thanks a lot.

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


Re: [Haskell-cafe] Re: ANN: A triple of new packages for talking to the outside world

2008-01-09 Thread Duncan Coutts

On Wed, 2008-01-09 at 09:26 +, Dominic Steinitz wrote:
> Adam Langley  imperialviolet.org> writes:
> 
> > But if this is useful to you, make any requests. I'll (hopefully) do
> > them, clean it up and push a new release of binary-strict.
> > 
> How difficult would it be to have a getBits functions as well as a getBytes?
> That would allow me drop the dependency on NewBinary in the ASN.1 package.

The difficulty is in deciding what the api should be. Does it give you a
real bitstream or only a byte aligned one? If I ask for 3 bits then 15
bytes what does it do? Does it assume I meant 3 bits, then pad to the
next byte boundary and get 15 bytes, or does it mean get 15 bytes but at
this 3 bit shift offset?

Duncan

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


[Haskell-cafe] Data.Binary and serialising doubles in IEEE format

2008-01-09 Thread allan

Dear all

I have what I think should be a relatively simple problem:
I have a C program which reads in data from a binary file, it is a 
specific format so it knows that there are 3 integers followed by three 
doubles or whatever. So I'm trying to serialise the data from within a 
Haskell program and write it out to a file such that the C program can 
read this.
I've gotten the integers to work no problem but I'm having difficulty 
with the doubles.


My method is to use the Data.Binary library to write the data out as a 
bytestring and then simply write this out to disk.
The problem is that the instance of Binary for  Double does not 
serialise the data in the format which is expected by the C program 
(standard IEEE format using fread and a cast).


Now there was a thread on (essentially) this very same topic on 
haskell-cafe back in April, see:

http://www.haskell.org/pipermail/haskell-cafe/2007-April/024596.html

There was some discussion about the 'right' thing to do and that the 
library intended to be split into two separate portions; one for users 
that wish to serialise their own data and have it readable by the same 
haskell program, and those that wish to communicate with programs 
written in other languages.


From the above thread:


Perhaps we just don't care about ARM or other arches where GHC runs that
do not use IEEE formats, I don't know. If that were the case we'd say
something like:

instance Binary Double where
  put d = assert (isIEEE (undefined :: Double)) $ do
write (poke d)


Now for my specific problem I'd be happy if I could write a function:
putDouble :: Double -> Put

and so obviously I tried:
putDouble :: Double -> Put
putDouble d = assert (isIEEE (undefined :: Double)) $ do
write (poke d)

However I seem to be stuck at this point, where does the 'write' 
function come from?


Essentially then, is there anyone that can write my 'putDouble' function 
or give some hint as to how I might do it.
For the moment assume that I'm not really concerned with portability 
across platforms at least for the time being (I certainly don't think 
that the C program I'm attempting to communicate with is particularly 
portable anyway).


kind regards
allan

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


Re: [Haskell-cafe] Re: Is there anyone out there who can translate C# generics into Haskell?

2008-01-09 Thread Jules Bean

Achim Schneider wrote:

Yes, you see, that was my first Haskell program bigger than 20 lines,
there's no possibility to get the state out of the IO Monad, at least
without writing a high-level interface to glut and gl, and then there's
this thing that _every_ game works with input callbacks, one, global,
state update function (where it doesn't _really_ matter whether you're
passing and returning a state or updating a state) and one function
that translates the state into some graphics representation.


Understood.

My objection was not about having an IORef somewhere (you need it to 
thread via the callback), but about making each component an IORef when 
one big IORef makes more sense.


It makes plenty of sense to try to write precise type signatures, 
including not having IO in the type of functions which don't do IO.


For ramblings about the annoyance of having to use IORefs to thread your 
custom monad state through callbacks, take a look at


http://www.haskell.org/pipermail/haskell-cafe/2007-July/028501.html

which sketches a typeclass "solution"

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


Re: [Haskell-cafe] Trouble with indentation

2008-01-09 Thread Jules Bean

Fernando Rodriguez wrote:


Hi,

I'm trying to write a function that finds out the week day using the 
Zeller congruence (http://en.wikipedia.org/wiki/Zeller's_congruence).


However, ghc complains about: parse error on input `=' at the "if m <= 2 
then " line. I believe this is some sort of layout error.  Can someone 
point out what I am doing wrong?


Here's the code:

data DiaSemana = Lunes | Martes | Miercoles | Jueves | Viernes
| Sabado | Domingo deriving (Show, Eq, Ord, Enum)
diaDeSemana d m a = toEnum num :: DiaSemana
where
num = zeller x y z
zeller x y z = (700 + (26 * x - 2) `div` 10
 + d + y + y `div` 4 + z `div` 4 - 2 * z)
 `mod` 7
if m <= 2 then x = m 
+ 10

y = (a - 1) `mod` 100
z = (a-1) 'div' 100
else x = m - 2
y = a  `mod` 100
z = a `div` 100



That looks like it's been mangled a bit by your mail program or mine, 
but anyway:


This is not a layout problem. The problem here is simply that you can't 
put "ifs" around chunks of definitions. "if" is an expression level 
concept, not a definition-level one.


You could try:

diaDeSemana d m a = toEnum num :: DiaSemana
where
num = zeller x y z
zeller x y z = (700 + (26 * x - 2) `div` 10
 + d + y + y `div` 4 + z `div` 4 - 2 * z)
 `mod` 7
x | m <= 2= m + 10
  | otherwise = m - 2
y | m <= 2= (a - 1) `mod` 100
  | otherwise = a  `mod` 100
z | m <= 2= (a-1) 'div' 100
  | otherwise = a `div` 100


or, to avoid the ugly duplication of the m <= 2 constraint, we can use 
an if in an expresson like this:


diaDeSemana d m a = toEnum num :: DiaSemana
where
num = zeller x y z
zeller x y z = (700 + (26 * x - 2) `div` 10
 + d + y + y `div` 4 + z `div` 4 - 2 * z)
 `mod` 7
(x,y,z) = if m <=2 then
 (m+10,(a-1)`mod`100,(a-1)`div`100)
  else
 (m-2,a`mod`100,a`div`100)


... or, replacing the if with guards again ...

diaDeSemana d m a = toEnum num :: DiaSemana
where
 num = zeller x y z
 zeller x y z = (700 + (26 * x - 2) `div` 10
  + d + y + y `div` 4 + z `div` 4 - 2 * z)
  `mod` 7
 (x,y,z)
   | m <=2 = (m+10,(a-1)`mod`100,(a-1)`div`100)
   | otherwise = (m-2 ,a`mod`100,a`div`100)

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


Re: [Haskell-cafe] Trouble with indentation

2008-01-09 Thread Dougal Stanton
On 09/01/2008, Fernando Rodriguez <[EMAIL PROTECTED]> wrote:
>
> However, ghc complains about: parse error on input `=' at the "if m <= 2
> then " line. I believe this is some sort of layout error.  Can someone point
> out what I am doing wrong?

Assuming the layout didn't get munged during the email process, the
problem is that the 'if' can't go there. You need to have 'sth = if
...' not 'if cond then sth = '

> diaDeSemana d m a = toEnum num :: DiaSemana
> where
> num = zeller x y z
> zeller x y z = (700 + (26 * x 
> - 2) `div` 10
> + d + y + y `div` 4 + 
> z `div` 4 - 2 * z)
> `mod` 7
> if m <= 2 then
> x = m + 10
> y = (a - 1) `mod` 100
> z = (a-1) 'div' 100
> else
> x = m - 2
> y = a  `mod` 100
> z = a `div` 100

Maybe try:

> (x,y,z) = if m <= 2
>  then (m+10, (a-1)`mod`100, (a-1)`div`100)
>  else (m-2 , a`mod`100, a`div`100)

I haven't tested this though

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] ANNOUNCE: Haddock version 2.0.0.0

2008-01-09 Thread Simon Marlow

Felipe Lessa wrote:

On Jan 8, 2008 10:28 AM, David Waern <[EMAIL PROTECTED]> wrote:

  * Haddock now understands all syntax understood by GHC 6.8.2


Does Haddock still define __HADDOCK__? There's a lot of code that uses
this flag just to hide something Haddock didn't know.


Haddock itself never defined __HADDOCK__, because it didn't do the CPP 
preprocessing itself.  Cabal adds __HADDOCK__ itself when preprocessing 
files for passing to Haddock.  When used with Haddock version 2, Cabal no 
longer defines __HADDOCK__ when preprocessing.


Haddock 2 can do the preprocessing itself, because it is processing the 
Haskell files using the GHC API.  In this case, if you want __HADDOCK__ 
defined, you have to add it explicitly with --optghc -D__HADDOCK__.


The easiest way to use Haddock 2 is via Cabal, which will automatically add 
the appropriate options for your package, including the right -B option 
which Haddock now needs in order that the GHC API can find its package 
database.


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


[Haskell-cafe] Trouble with indentation

2008-01-09 Thread Fernando Rodriguez


Hi,

I'm trying to write a function that finds out the week day using the Zeller 
congruence (http://en.wikipedia.org/wiki/Zeller's_congruence).


However, ghc complains about: parse error on input `=' at the "if m <= 2 
then " line. I believe this is some sort of layout error.  Can someone point 
out what I am doing wrong?


Here's the code:

data DiaSemana = Lunes | Martes | Miercoles | Jueves | Viernes
| Sabado | Domingo deriving (Show, Eq, Ord, 
Enum)
diaDeSemana d m a = toEnum num :: DiaSemana
where
num = zeller x y z
zeller x y z = (700 + (26 * x - 
2) `div` 10
+ d + y + y `div` 4 + z 
`div` 4 - 2 * z)
`mod` 7
		if m <= 2 then 
			x = m + 10

y = (a - 1) `mod` 100
z = (a-1) 'div' 100
		else 
			x = m - 2

y = a  `mod` 100
z = a `div` 100



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


Re: Fusion vs. inlining (Was: [Haskell-cafe] Fusion of lists and chunky sequences)

2008-01-09 Thread Henning Thielemann

On Tue, 8 Jan 2008, Roman Leshchinskiy wrote:

> Henning Thielemann wrote:
> >
> > Anyway, I tried to wrap Prelude lists in a newtype and thus got GHC (still
> > 6.4.1) to invoke my rules instead of the Prelude rules. But I encountered
> > the following problem: I define something like
> >
> >   nonFusable x y = fusable (aux x y)
> >
> >  where fusion rules are defined for 'fusable', but not for 'nonFusable'. I
> > hoped that 'nonFusable' will be inlined and then 'fusable' is fused with
> > other expressions. This does not happen. If I state the function
> > definition also as rule, then GHC fuses eagerly.
>
> I suspect that fusable and/or aux are inlined into nonFusable when the
> latter is compiled. That's too early - you want nonFusable (with the
> simple definition above) to be inlined into the client code first. Adding
>
>{-# INLINE nonFusable #-}
>
> should take care of this.

I forget to mention, that I already declared
  {-# INLINE nonFusable #-}

As you guessed, it seems that 'fusable' was inlined and thus was no longer
available for fusion. So I set INLINE for nonFusable and NOINLINE for
fusable. Now I see the foldr/build counter decreases in the simplifier
statistics, where the counter for my custom rules increases.


> >  Analogously I observed that usage of ($) and (.) blocks fusion, and when
> > I add the rules
> >
> >   "unfold-dollar" forall f x.
> >  f $ x = f x ;
> >
> >   "unfold-dot" forall f g.
> >  f . g  =  \x -> f (g x) ;
> >
> >  then fusion takes place as expected.
>
> That shouldn't be necessary, these two ought to be inlined. Do you have
> a concrete example where this happens?

 When I constructed a small example I encountered the behaviour you
mentioned. However there are still several cases where I expected that
fusion took place but it didn't. Maybe I can track them down to very
simple cases. Since the functions on the chunky structure can be faster
than the list functions by a factor of 30, I'm very keen on getting the
list functions eliminated completely.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Currying and Partial Evaluation

2008-01-09 Thread Achim Schneider
Derek Elkins <[EMAIL PROTECTED]> wrote:

> Can we stop using confusing, misleading or outright wrong definitions
> and analogies?
>
No, we can't, ever, that's plain impossible. And will never stop to use
enlightening, inspiring or vastly approximate or aggregate definitions
and analogies, and I won't stop laughing about my mistakes.

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

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


[Haskell-cafe] Re: PROPOSAL: Some more 'Applicative' combinators

2008-01-09 Thread apfelmus

Sterling Clover wrote:
The more general question, which stems from a certain degree of 
ignorance on my part, is what uses folks have found for Alternative at 
all outside of parsing.


Alternative is the generalization of MonadPlus, so  empty  and  <|>  are 
useful for lists and Maybe at least. But I'm not sure whether


   many :: Alternative f => f a -> f [a]

and friends have any uses outside of parsing.


Regards,
apfelmus

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


[Haskell-cafe] Re: Currying and Partial Evaluation

2008-01-09 Thread Fernando Rodriguez

Hello Jules,



I'm not sure you got a straight answer, although you provoked some
discussion.


Thanks for your answer, now everything is much clearer. 




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


Re: [Haskell-cafe] Re: Type System (Was: Currying and Partial Evaluation)

2008-01-09 Thread Felipe Lessa
On Jan 9, 2008 12:39 AM, Achim Schneider <[EMAIL PROTECTED]> wrote:
> Yes, exactly that wire which isn't obscured by the boiler plate has
> kindled my interest.

The name of a type variable doesn't really matter. GHC tries to
preserve the names you give, otherwise it creates their own. For
example,

Prelude> :t \a b c d e f g -> (a,b,c,d,e,f,g)
\a b c d e f g -> (a,b,c,d,e,f,g) :: t
-> t1
-> t2
-> t3
-> t4
-> t5
-> t6
-> (t, t1, t2, t3, t4, t5, t6)

Welll, so why 'b'? Well, GHC didn't choose 'b' at all =)

Prelude> :t let y f = f (y f) in y
let y f = f (y f) in y :: (t -> t) -> t

but

Prelude> :t let y f = f $ y f in y
let y f = f $ y f in y :: (b -> b) -> b

because

Prelude> :t ($)
($) :: (a -> b) -> a -> b

In another exemple,

Prelude> :t \a b c d e f g -> (id a,b,c,d,e,f,g)
\a b c d e f g -> (id a,b,c,d,e,f,g) :: a -> t -> t1 -> t2 -> t3 -> t4
-> t5 -> (a, t, t1, t2, t3, t4, t5)
Prelude> :t \a b c d e f g -> (a,b,c,d,id e,f,g)
\a b c d e f g -> (a,b,c,d,id e,f,g) :: t -> t1 -> t2 -> t3 -> a -> t4
-> t5 -> (t, t1, t2, t3, a, t4, t5)
Prelude> :t \a b c d e f g -> (a,b,id c,d,id e,f,g)
\a b c d e f g -> (a,b,id c,d,id e,f,g) :: t -> t1 -> a -> t2 -> a1 ->
t3 -> t4 -> (t, t1, a, t2, a1, t3, t4)



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


Re: [Haskell-cafe] Currying and Partial Evaluation

2008-01-09 Thread Jules Bean

Fernando Rodriguez wrote:


Hi,

Is currying in Haskell the same thing as Partial Evaluation 
(http://en.wikipedia.org/wiki/Partial_evaluation)? Am I getting partial 
evaluation for free just by using Haskell?

Thanks!


I'm not sure you got a straight answer, although you provoked some 
discussion.


Currying is the transformation which takes a function which takes 
multiple parameters "all at once", into a function which takes one 
parameter, returning a function which takes one more parameter, 
returning


I.e.:

uncurried function:

f :: (a,b,c,d) -> e

takes four parameters "all at once". In haskell it has to take them as a 
tuple.


The corresponding curried function:

f :: a -> b -> c -> d -> e

Takes one parameter (of type a), and returns a function of type (b -> c 
-> d ->e). This takes one parameter of type b, and returns a function of 
type (c -> d -> e). This takes one parameter of type c and returns a 
function of type (d -> e). This takes one parameter of type d and 
returns a result of type e.


So, in the end, both forms of f take four parameters and give a result 
of type e. The difference is that the curried form takes them "one at a 
time", and you can "stop partway" with only some of the parameters supplied.


This process of "stopping partway" is called "partial application" (not 
partial evaluation), and it's a useful technique when working with 
higher-order functions.


Convention in haskell, ML, and similar languages is to use the curried 
style predominantly. This is for a variety of reasons; the most 
practically oriented reason is simply that it makes partial application 
straightforward, which is a useful technique.


Now for the second half of your question!

Partial Evaluation is cool, but nobody has worked out a good way to get 
it for free. Some compilers do some kinds of partial evaluation. The 
"constant folding" that most C compilers do is a very simple case of 
partial evaluation.


In principle, languages like haskell give the compiler a lot more 
information to determine how much partial evaluation is feasible 
(especially that the compiler knows which functions are pure). It 
remains an interesting engineering problem working out which bits to do, 
though. GHC does not do very much partial evaluation, although some of 
its optimisations (SpecConstr and some RULES pragmas) are 
partial-evaluation in a sense.


Neil Mitchell's interesting (but as far as I know, work-in-progress) 
Supero project, http://www-users.cs.york.ac.uk/~ndm/supero/ , is a 
closely related notion of compilation.


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


[Haskell-cafe] Re: ANN: A triple of new packages for talking to the outside world

2008-01-09 Thread Dominic Steinitz
Adam Langley  imperialviolet.org> writes:

> But if this is useful to you, make any requests. I'll (hopefully) do
> them, clean it up and push a new release of binary-strict.
> 
How difficult would it be to have a getBits functions as well as a getBytes?
That would allow me drop the dependency on NewBinary in the ASN.1 package.

Thanks, Dominic.

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


Re: [Haskell-cafe] US Homeland Security program language security risks

2008-01-09 Thread Yitzchak Gale
Galchin Vasili wrote on Friday, January 4:
>>  I stumbled across this page. It seems that Haskell and other
>> strongly typed functional languages like Ml/OCaml will fare much,
>> much better, e.g. buffer overrun. Thoughts .  comments.

Bulat Ziganshin wrote:
> for me, it looks like saying that haskell better uses CPU registers :)
> the truth is that modern languages (including Java/C#) doesn't use
> buffers directly. i don't have experience of their usage, but for
> Haskell i had memory referencing problems only when using unsafe*
> tricks

Interestingly enough, a few days after this exchange, the
first public report was released from a large survey funded
by US Homeland Security on security of open source
projects. The survey was carried out by a company
called Coverity.

Among the projects making top grade for security - apparently
far better than most proprietary products, though complete
information about that is not public - were PHP, Perl, and
Python.

PHP? Come on, can't we do at least as well? But right now,
there is a technical impediment to the participation of
Haskell: the Coverity project currently only supports
projects written in C, C++, and Java. Haskell compilers
are often written in Haskell.

Any ideas? Perhaps Coverity's interest could be
piqued if they were made aware of Haskell's emergence
as an important platform in security-sensitive
industries such as finance and chip design, and of
the significant influence that Haskell is having on the
design of all other major programming languages.

The home page for the Coverity open source project
is at:

http://scan.coverity.com/

Some recent press coverage:

http://it.slashdot.org/article.pl?sid=08/01/09/0027229

http://www.zdnet.com.au/news/security/soa/11-open-source-projects-pass-security-health-check/0,130061744,339284949,00.htm

http://www.informationweek.com/story/showArticle.jhtml?articleID=205600229

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


Re: [Haskell-cafe] ANN: A triple of new packages for talking to the outside world

2008-01-09 Thread Don Stewart
bos:
> Adam Langley wrote:
> 
> > Ok, see http://www.imperialviolet.org/IncrementalGet.hs
> 
> That's excellent!  This is just the sort of thing one wants if getting
> dribs and drabs of information instead of a steady stream.  For example,
> I need to reconstruct TCP streams from individual packets captured off
> the wire, and this is a much easier mechanism to use than playing tricks
> with the direct-mode Get monad.
> 
> > Questions:
> >   1) Should Finished include the remainder of the ByteString (e.g.
> > that which wasn't used by that parser)
> 
> Yes, definitely.  I had to add a runGetState to the existing Get monad
> so that I could recover the unparsed residual, so I'm sure it will be
> necessary here.
> 
> >   2) I've no idea what I've done to the parse speed
> 
> Getting the API right is the appropriate thing to be doing first.
> Afterwards, the rewrite rule ninjas can stage a night attack on
> performance problems.

Yeah, I'm happy to attack that problem. The key is finding a useful API
that you actually can work with for real problems. This looks like a
good step -- and interesting to see how you're needs differed from 
the original intent.

> > But if this is useful to you, make any requests. I'll (hopefully) do
> > them, clean it up and push a new release of binary-strict.
> 
> I'm lobbying for Don and company to include this stuff in the regular
> binary distribution.  A proliferation of almost-identical packages
> doesn't serve the community all that well.

I'm happy to -- if people need a slightly different API, we should do
what we can to support that. 

The goal is to make binary hacking in Haskell painless, so anything that
helps that goal, is good :)

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