[Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-19 Thread Dummy
Hi,
 
i am really happy about this lively discussion around Haskell (Mac) GUIs.
 
I might hint to two other options:
 
1) Eclipse's SWT wraps the native platform's toolkits quite sucessfully.
The platform-dependent bindings are mostly automatically generated, afaik.
Some time ago i summarized my thoughts about extending SWT's infrastructure/code
for Haskell here:
http://www.reddit.com/r/haskell_proposals/comments/9w7nk/adjust_the_swt_binding_generators_for_haskell/
 
2) Ruby's Shoes provides simple native wrappers as i've pointed out on Reddit:
http://www.reddit.com/r/haskell/comments/he8pl/status_of_haskell_mac_guis_graphics/

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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-19 Thread Sam Martin
 My conclusion was that GLFW-b (on hackage) is the best we have right
 now.  I think we could do even better than the C libraries out there
 by writing the GLUT/GLFW/etc implementation purely in Haskell.  We
 already have x11 and gtk bindings for the linux support.  We have
 win32 api bindings for windows support.  What we are lacking is good
 low level support for OSX GUI programming.  Once we have that it's not
 too much of a stretch to use cabal to glue it together into a cross
 platform library.  I believe that's the right way to go for the long
 term.  Improving GLFW-b is a good short-term route.

I agree with your approach. Although getting a window on screen really isn't 
much code, so I'd vote for going straight to a Haskell replacement for GLUT et 
al. 

 And just to say it one more time, I can use all the help I can get.

I don't have much time, but if someone started a github project for a Haskell 
GLUT replacement I could probably chip in here and there. 

Ta,
Sam

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


Re: [Haskell-cafe] blaze-builder and FlexibleInstances in code that aims to become part of the Haskell platform

2011-05-19 Thread Johan Tibell
Hi Simon,

On Wed, May 18, 2011 at 7:32 PM, Simon Meier iridc...@gmail.com wrote:
 In fact, one of my current goals with this work is to polish it such
 that it can be integrated into the 'bytestring' library.

We should definitely add a builder monoid in the bytestring package.

Since Write mentions IO, I thought I should point out that we need to
separate any code that mentions IO from the the code that doesn't
(i.e. the pure Builder API). The use of IO is an implementation detail
in bytestring. We should follow the existing bytestring pattern and
put any code that mentions IO in e.g.
Data.ByteString.Lazy.Builder.Internal. This allows the few people who
need to access the internals to do so while making it clear that these
are in fact internals. Long term we'd like to switch bytestring over
from ForeignPtr to ByteArray#, if possible. There are currently some
technical obstacles to such a switch, but factoring out the IO code at
least makes it somewhat easier if we ever get around to switching.

Avoiding IO in the main API means that the main builder type must not
mention IO (or things related to IO, such as Storable).

 The core principle used to tackle (1) is avoiding intermediate data
 structures.  The core abstraction used is the one of a Write (see [1]
 for the corresponding library.)

  data Write a = Write Int (a - Ptr Word8 - IO (Ptr Word8))

 A value `Write bound io :: Write a` denotes an encoding scheme for
 values of type `a` that uses at most `bound` bytes space. Given a
 values `x :: a` and a pointer `po` to the next free byte `io x po`
 encodes `x` to memory starting from `po` and returns the pointer to
 the next free byte after the encoding of `x`.

 In most cases Writes are used as an abstract datatype. They serve as
 an interface between implementors of the low-level bit-twiddling
 required to efficiently implement encodings like UTF-8 or Base16 and
 the providers of efficient traversal functions through streams of
 Haskell values. Hence, typical users of Writes are functions like

  fromWrite          :: Write a - a - Builder
  fromWriteList      :: Write a - [a] - Builder
  fromWriteUnfoldr   :: Write b - (a - Maybe (b, a)) - a - Builder
  mapWriteByteString :: Write Word8 - S.ByteString - Builder

We want to allow users to efficiently create new builders, for their
own data type. This is crucial as the bytestring package cannot
provide efficient builders for every possible type, as it would have
to depend on most of Hackage (i.e. on all packages that define types
that we want efficient builders for) to do so. Allowing the user to
get hold of the underlying buffer in a controlled way makes the
builder extensible. This is good.

Write achieves this separation, but it has some costs which I'm not
entirely comfortable with.

First, it leads to lots of API duplication. For every type (e.g. Word)
we want to be able serialize we have two morally identical functions

writeWordhost :: Word - Write
fromWordhost :: Word - Builder

in the API, where the latter simply calls the former and does some
additional wrapping.

See 
http://hackage.haskell.org/packages/archive/blaze-builder/0.3.0.1/doc/html/Blaze-ByteString-Builder-Word.html
for examples.

Simon, is the reason for this duplication this comment on top of
Blaze.ByteString.Builder.Word?

Note that for serializing a three tuple (x,y,z) of bytes (or other
word values) you should use the expression

fromWrite $ writeWord8 x `mappend` writeWord8 y `mappend` writeWord z

instead of

fromWord8 x `mappend` fromWord8 y `mappend` fromWord z

The first expression will result in a single atomic write of three
bytes, while the second expression will check for each byte, if
there is free space left in the output buffer. Coalescing these
checks can improve performance quite a bit, as long as you use it
sensibly.

Coalescing of buffer space checks can be achieved without separating
writes into Write and Builder. I've done so in the binary package [1]
using rewrite rules. The rewrite rules fire reliable so that any
syntactic series of puts i.e.

f = do
putWord8 1
putWord8 2
putWord8 3

result in one bounds check, followed by three pokes into the buffer.
To do so all that is needed is to define all builders in terms of

writeAtMost :: Int - (Ptr Word8 - IO Int) - Builder

and create a rewrite rule for append/writeAtMost. writeAtMost is
essentially the same as your Write [2], except it never leads to any
constructors getting allocated.

At the moment, the addition of Write means that

import Blaze.ByteString.Builder

f :: [Word8] - Builder
f xs = fromWriteList writeWord8 xs

is faster than the Data.Binary equivalent

import Data.Binary.Builder

g :: [Word8] - Builder
g [] = mempty
g (x:xs) = singleton x `mappend` g xs

Fortunately this was due to a bug in GHC [3]. After this bug has been
fixed I expect Data.Binary to perform on par with
Blaze.ByteString.Builder, 

Re: [Haskell-cafe] blaze-builder and FlexibleInstances in code that aims to become part of the Haskell platform

2011-05-19 Thread Henk-Jan van Tuyl
On Wed, 18 May 2011 23:21:27 +0200, Antoine Latter aslat...@gmail.com  
wrote:



I don't have a problem with these extensions being in the Haskell
Platform, as the platform currently only targets GHC, but the
bytestring package itself might have a higher standard of portability.


So you want the packages that use extensions thrown out, as soon as  
another Haskell compiler becomes popular? As one of the targets of the  
Haskell Platform is stability, it is not advisable to target just one  
compiler.


Regards,
Henk-Jan van Tuyl


--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--

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


Re: [Haskell-cafe] blaze-builder and FlexibleInstances in code that aims to become part of the Haskell platform

2011-05-19 Thread Antoine Latter
On May 19, 2011 4:57 AM, Henk-Jan van Tuyl hjgt...@chello.nl wrote:

 On Wed, 18 May 2011 23:21:27 +0200, Antoine Latter aslat...@gmail.com
wrote:

 I don't have a problem with these extensions being in the Haskell
 Platform, as the platform currently only targets GHC, but the
 bytestring package itself might have a higher standard of portability.


 So you want the packages that use extensions thrown out, as soon as
another Haskell compiler becomes popular? As one of the targets of the
Haskell Platform is stability, it is not advisable to target just one
compiler.


Portability and adherence to standards is a goal worth striving for, but the
platform policy stated on the wiki is that packages in the platform should
build on all compilier targets.

I think we need to be pragmatic about what we include - for example
functional dependencies are still controversial, but that doesn't mean that
the 'mtl' package should be tossed out of the platform.

But perhaps it does mean that, for example, the 'containers' package should
be subject to a higher level of scutiny for its public API. The 'bytestring'
package might also be such a package where we prioritize portability.

I'm not active in the maintaince of the platform; perhaps I'm mis-stating
the goals and policies.

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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-19 Thread Heinrich Apfelmus

Jason Dagit wrote:


As you point out we also need better libraries for creating the OpenGL
context.  I wrote up my searches on that front here:
http://blog.codersbase.com/2011/03/picking-gui-library-to-use-with-opengl.html

My conclusion was that GLFW-b (on hackage) is the best we have right
now.  I think we could do even better than the C libraries out there
by writing the GLUT/GLFW/etc implementation purely in Haskell.


Not sure about that. I have looked at the GLFW source code, it's the 
cleanest C code I have ever seen and definitely worth contributing to. 
The thing with established cross-platform GUI toolkits is that they 
embed a lot of wisdom about platform quirks (Cocoa is particularly 
annoying) that you would have to solve again.



Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-19 Thread Heinrich Apfelmus

Conal Elliott wrote:

Last I heard, wx still had the problem of crashing its host the second time
one opens a window (which is typical in ghci). And last I heard, Jeremy
O'Donoghue (cc'd) was exploring solutions but had very little time to pursue
them.  - Conal


Last I remember, the latest problem is that ghci is unable to link 
libstdc++. But the crash problem is probably still there.



Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


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


[Haskell-cafe] Trying to return a map from State monad

2011-05-19 Thread michael rice
I'm not sure what's going on BELOW. Was working with mapAccumL earlier and 
decided to move over to State monad for more control.
:m + Data.Map:m + Data.ListPrelude Data.List Data.Map let f key new old = new 
++ oldPrelude Data.List Data.Map let moby2 = Moby Dick is a great book. Moby 
Dick was a white whale.Prelude Data.List Data.Map fst $ mapAccumL (\ (m,p) w 
- ((insertWithKey' f p [w] m, (snd p, w)),)) (singleton (\n, \n) [], 
(\n,\n)) (words moby2)(fromList 
[((\n,\n),[Moby]),((\n,Moby),[Dick]),((Dick,is),[a]),((Dick,was),[a]),((Moby,Dick),[was,is]),((a,great),[book.]),((a,white),[whale.]),((book.,Moby),[Dick]),((great,book.),[Moby]),((is,a),[great]),((was,a),[white])],(white,whale.))
Michael

BELOW===
import Control.Monad.Stateimport Data.Map
type Prefix = (String,String)type GeneratorState = (Map Prefix 
[String],Prefix,[String])
non_word = \n
f key new old = new ++ old 
buildMap :: GeneratorState (Map Prefix [String])  buildMap = do 
(mp,(pfx1,pfx2),all@(w1:words)) - get              if (Prelude.null all)       
         then  {- No more words. Return final map (adding non_word for prefix). 
-}                  return (insertWithKey' f (pfx1,pfx2) [non_word] mp)         
       else  {- Add word to map at prefix. Continue. -}                  put 
(insertWithKey' f (pfx1,pfx2) [w1] mp, (pfx2,w1), words)                  
buildMap
==
Prelude :l markov3.hs[1 of 1] Compiling Main             ( markov3.hs, 
interpreted )
markov3.hs:11:12:    `GeneratorState' is applied to too many type arguments    
In the type signature for `buildMap':      buildMap :: GeneratorState (Map 
Prefix [String])Failed, modules loaded: none.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Trying to return a map from State monad

2011-05-19 Thread Thedward Blevins
On Thu, May 19, 2011 at 11:03, michael rice nowg...@yahoo.com wrote:
 type GeneratorState = (Map Prefix [String],Prefix,[String])

 buildMap :: GeneratorState (Map Prefix [String])

You are trying to use a type alias (GeneratorState) as a type constructor.

There may be other problems, but that leaps out.

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


Re: [Haskell-cafe] Trying to return a map from State monad

2011-05-19 Thread michael rice
Ok, I see I left out the State word.
Should be:type GeneratorState = State (Map Prefix [String],Prefix,[String])
Thanks,
Michael

--- On Thu, 5/19/11, Thedward Blevins thedw...@barsoom.net wrote:

From: Thedward Blevins thedw...@barsoom.net
Subject: Re: [Haskell-cafe] Trying to return a map from State monad
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Thursday, May 19, 2011, 12:22 PM

On Thu, May 19, 2011 at 11:03, michael rice nowg...@yahoo.com wrote:
 type GeneratorState = (Map Prefix [String],Prefix,[String])

 buildMap :: GeneratorState (Map Prefix [String])

You are trying to use a type alias (GeneratorState) as a type constructor.

There may be other problems, but that leaps out.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] For Euler 25; What is the first term in the Fibonacci sequence to contain 1000 digits?; the following seems to work.

2011-05-19 Thread KC
For Euler 25; What is the first term in the Fibonacci sequence to
contain 1000 digits?; the following seems to work.


-- For number of digits being 5 or more.
fibNdigits :: Int - Int
fibNdigits nDigits = floor (((fromIntegral nDigits) - 1.0) / (logBase
10 phi)) + 2
  where
sq5 = sqrt 5 :: Double
phi = (1 + sq5) / 2


-- 
--
Regards,
KC

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


Re: [Haskell-cafe] No fish, please

2011-05-19 Thread Andrew Coppin

This is basically the reason I asked. Currently Cabal assumes that
Haddock is the only tool of its kind. If somebody built a better
Haddock, you wouldn't be able to use it. (Unless you named the
executable haddock and made it accept the same command options.)


Or maybe support for that tool would be integrated into Cabal and cabal and
hackage.


I believe the correct approach would be to make it easy to configure 
Cabal to use any tool that might be produced one day, rather than 
integrating support for each specific tool that actually exists.



But even while such a tool is not yet available, it would be worth thinkng
about hackage offering the possibility to display other docs than haddock-
generated ones.


Agreed.


IF you do have better docs, host them somewhere, and put a link
prominently in the .cabal file synopsis.


That works, but it does mean that you can't read the documentation
offline.


Make it downloadable?
Include the docs in the package (extra-source-files: thedocs.tar.gz) and
mention it in the package descripiton for a (less than optimal) workaround.


I thought extra-source-files: is only for Haskell source code?


(It also requires you to have somewhere to host, which not
everybody has.


Haskellwiki, bitbucket, github, ...


BitBucket only works for Mercurial, GitHub only works for Git. The 
Haskell wiki might be OK, and has the nice advantage that other people 
can improve it. (Do we think Hackage will ever get a wiki per package?) 
The other thing is, you can bet as soon as you put your package's 
documentation on the wiki and link it from the package description, the 
URL will change at some point, breaking the link.



Sure, a centralised documentation-hosting would have advantages over
sprinkling over all the free project-hosting services, but the situation is
not unbearably dire as is.


Granted. I'm just saying how it could be better.

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


Re: [Haskell-cafe] No fish, please

2011-05-19 Thread Andrew Coppin

On 18/05/2011 11:25 PM, Ivan Lazar Miljenovic wrote:

On 19 May 2011 08:09, Daniel Fischerdaniel.is.fisc...@googlemail.com  wrote:

On Wednesday 18 May 2011 23:39:47, Andrew Coppin wrote:

(It also requires you to have somewhere to host, which not
everybody has.


Haskellwiki, bitbucket, github, ...


Also if you have a project on code.haskell.org, then you also can have
a website for it on projects.haskell.org


Today is the first time I've seen these domain names mentioned. (They 
appear to be aliases to the same server that runs the rest of 
haskell.org...)


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


[Haskell-cafe] The Lisp Curse

2011-05-19 Thread Andrew Coppin

http://www.winestockwebdesign.com/Essays/Lisp_Curse.html

Some of you might have seen this. Here's the short version:

  Lisp is so powerful that it discourages reuse. Why search for and 
reuse an existing implementation, when it's so trivially easy to 
reimplement exactly what you want yourself? The net result is a maze of 
incompatible libraries which each solve a different 80% of the same problem.


To all the people who look at Hackage, see that there are 6 different 
libraries for processing Unicode text files, and claim that this is 
somehow a *good* thing, I offer the above essay as a counter-example.


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


Re: [Haskell-cafe] For Euler 25; What is the first term in the Fibonacci sequence to contain 1000 digits?; the following seems to work.

2011-05-19 Thread Sebastian Fischer
On Thu, May 19, 2011 at 7:29 PM, KC kc1...@gmail.com wrote:

 For Euler 25; What is the first term in the Fibonacci sequence to
 contain 1000 digits?; the following seems to work.


 -- For number of digits being 5 or more.
 fibNdigits :: Int - Int
 fibNdigits nDigits = floor (((fromIntegral nDigits) - 1.0) / (logBase
 10 phi)) + 2
  where
sq5 = sqrt 5 :: Double
phi = (1 + sq5) / 2



(length . show) is fast enough for me. The following gives the answer in a
fraction of a second.

# cabal install fibonacci
# ghci
ghci import Data.Numbers.Fibonacci
ghci head . filter ((==1000) . length . show) $ map fib [0..]
10700662663827589367649805844573968850836838966321516650132352033753145206046940406218891475824897926578046948881775919574843364666725699595129960304612627480924821861440694330512347744427502737817530875793916661921492591867595539664228371489431130746995034395470019854326097230672901928705264472437261177158218255484911205250132014786129659313817922355596574520395061375514678375432291196021299340482607061753977068470682028954869026661854351245219003694806413574474709117076197669456910700980243934396174741037369125032313655321647736970231677550515951735184605799549194109677783732296657965816465139034881542563101842241902598460880001101862024549393711365165703944762958471454852342595042858242530608354443542821261100899286379504800689433030977321783486454311320576565986845628861680871869383529735064398629764066723562917905207051164077614812491885830945940566688339109350944456576357666151619317753792891661581327159616877487983821820492520348473874384736771934512787029218636250627816
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Vo Minh Thu
2011/5/19 Andrew Coppin andrewcop...@btinternet.com:
 http://www.winestockwebdesign.com/Essays/Lisp_Curse.html

 Some of you might have seen this. Here's the short version:

  Lisp is so powerful that it discourages reuse. Why search for and reuse an
 existing implementation, when it's so trivially easy to reimplement exactly
 what you want yourself? The net result is a maze of incompatible libraries
 which each solve a different 80% of the same problem.

 To all the people who look at Hackage, see that there are 6 different
 libraries for processing Unicode text files, and claim that this is somehow
 a *good* thing, I offer the above essay as a counter-example.

Hi Andrew,

So what exactly is the problem on hackage and what do you propose as a solution?

Surely you don't want people to upload a library on hackage only once
it is perfect (nor do you think such a perfect, one-size-fits-all
library might exist)?

I haven't read the provided link but I also guess you don't _really_
mean that the referred packages on hackage were 'so trivially easy to
reimplement', nor that it is not possible to use them together...

Cheers,
Thu

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Serguey Zefirov
I think this is much less applicable to Haskell than to Lisp.

I think that most of intra-incompatibilities of Lisp stem from side
effects. The rest is mostly due to (relatively) weak type system which
let some errors slip.

And remaining percent or two can be attributed to the power of Lisp. ;)

2011/5/19 Andrew Coppin andrewcop...@btinternet.com:
 http://www.winestockwebdesign.com/Essays/Lisp_Curse.html

 Some of you might have seen this. Here's the short version:

  Lisp is so powerful that it discourages reuse. Why search for and reuse an
 existing implementation, when it's so trivially easy to reimplement exactly
 what you want yourself? The net result is a maze of incompatible libraries
 which each solve a different 80% of the same problem.

 To all the people who look at Hackage, see that there are 6 different
 libraries for processing Unicode text files, and claim that this is somehow
 a *good* thing, I offer the above essay as a counter-example.

 ___
 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] The Lisp Curse

2011-05-19 Thread Serguey Zefirov
2011/5/19 Vo Minh Thu not...@gmail.com:
 2011/5/19 Andrew Coppin andrewcop...@btinternet.com:
 http://www.winestockwebdesign.com/Essays/Lisp_Curse.html

 Some of you might have seen this. Here's the short version:

  Lisp is so powerful that it discourages reuse. Why search for and reuse an
 existing implementation, when it's so trivially easy to reimplement exactly
 what you want yourself? The net result is a maze of incompatible libraries
 which each solve a different 80% of the same problem.

 To all the people who look at Hackage, see that there are 6 different
 libraries for processing Unicode text files, and claim that this is somehow
 a *good* thing, I offer the above essay as a counter-example.

 So what exactly is the problem on hackage and what do you propose as a 
 solution?

The problem is that you have to try several packages before you get to
the stable point.

The solution... I think that some ratings, like used directly by ###
packages/projects and indirectly by ### would be nice, but not much.

As for me, I like the diversity of packages. They attack close
problems from different fronts. They express different ideas and
views. I like all that.

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Gilberto Garcia
I think what Andrew meant is that it's not a good idea to have big
pile of different implementations of the same library, and all trying
to solve the very same problem.

I see this kind of problem in the java community. It seems that
developers have a need to create everything from scratch more than
making existing ones better.

Short history, for example, why do we have to have N libraries to read
a file? can't we have just one damn good one?

Cheers

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


Re: [Haskell-cafe] No fish, please

2011-05-19 Thread Daniel Fischer
On Thursday 19 May 2011 20:27:16, Andrew Coppin wrote:
  This is basically the reason I asked. Currently Cabal assumes that
  Haddock is the only tool of its kind. If somebody built a better
  Haddock, you wouldn't be able to use it. (Unless you named the
  executable haddock and made it accept the same command options.)
  
  Or maybe support for that tool would be integrated into Cabal and
  cabal and hackage.
 
 I believe the correct approach would be to make it easy to configure
 Cabal to use any tool that might be produced one day, rather than
 integrating support for each specific tool that actually exists.
 

Well, 'any tool that might be produced one day' is perhaps a bit much to 
ask for, but making it easier to use other tools would be a good thing. The 
problem is, how?

 
 I thought extra-source-files: is only for Haskell source code?
 

No, README, CHANGES, such stuff. Putting a doc-tarball there might be 
abusing it, but while there's no better option ...

  (It also requires you to have somewhere to host, which not
  everybody has.
  
  Haskellwiki, bitbucket, github, ...
 
 BitBucket only works for Mercurial, GitHub only works for Git. The

Sure, I don't spell 'perfect' that way either.

 Haskell wiki might be OK, and has the nice advantage that other people
 can improve it. (Do we think Hackage will ever get a wiki per package?)
 The other thing is, you can bet as soon as you put your package's
 documentation on the wiki and link it from the package description, the
 URL will change at some point, breaking the link.
 
  Sure, a centralised documentation-hosting would have advantages over
  sprinkling over all the free project-hosting services, but the
  situation is not unbearably dire as is.
 
 Granted. I'm just saying how it could be better.

Agreed.


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


[Haskell-cafe] where is it appropriate to write library-related suggestions?

2011-05-19 Thread Nicholas Tung
Hi all,

I am curious if there is an avenue to make suggestions / comments about
libraries? For example, proc in System.Process conflicts with the Arrows
notation proc, yielding confusing error messages.

thanks,
Nicholas — https://ntung.com — CS and Mathematics major @ UC Berkeley
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Daniel Patterson
Correct my ignorance as I'm rather new around here, but I'm not sure if I 
actually think this happens that much. 

Different approaches are often put forth, which does mean that there are 
incompatible libraries that fill the same space for a while, but it seems that 
once it becomes clear what the best approach is, that becomes pretty well 
accepted. Are there really example of multiple libraries that use the same 
approach to solve the same problem that are incompatible and actively used? 
Right now there are a bunch of iteratee/enumerator/whatever term you want to 
call it libraries, but those are new ideas, and it isn't clear yet what the 
best approach is. 

In an open source community, there will always be multiple approaches to common 
problems. If as soon as one person came up with a solution, all others had to 
build upon that, there would be no progress, as no one would be able to try out 
new ideas. 

What is important is that there is visibility for packages so that people can 
see what else is out there and can decide if it makes the most sense to:
A. use an existing solution
B. improve an existing solution
C. start from scratch, because of wanting a fundamentally different approach.

I think hackage provides that. So what's the problem?

 Short history, for example, why do we have to have N libraries to read
 a file? can't we have just one damn good one?

The only way to get there is to have many solutions and then decide what the 
best one is!

Just my .02

On May 19, 2011, at 2:56 PM, Gilberto Garcia wrote:

 I think what Andrew meant is that it's not a good idea to have big
 pile of different implementations of the same library, and all trying
 to solve the very same problem.
 
 I see this kind of problem in the java community. It seems that
 developers have a need to create everything from scratch more than
 making existing ones better.
 
 
 Cheers
 
 ___
 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] where is it appropriate to write library-related suggestions?

2011-05-19 Thread Henning Thielemann


On Thu, 19 May 2011, Nicholas Tung wrote:


Hi all,
    I am curious if there is an avenue to make suggestions / comments about 
libraries?
For example, proc in System.Process conflicts with the Arrows notation proc,
yielding confusing error messages.


For the base libraries, you may e-mail to: librar...@haskell.org

Are there still problems, if you import 'proc' with qualification?

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


Re: [Haskell-cafe] where is it appropriate to write library-related suggestions?

2011-05-19 Thread Nicholas Tung
On Thu, May 19, 2011 at 3:21 PM, Henning Thielemann 
lemm...@henning-thielemann.de wrote:


 On Thu, 19 May 2011, Nicholas Tung wrote:

  Hi all,
 I am curious if there is an avenue to make suggestions / comments
 about libraries?
 For example, proc in System.Process conflicts with the Arrows notation
 proc,
 yielding confusing error messages.


 For the base libraries, you may e-mail to: librar...@haskell.org

 Are there still problems, if you import 'proc' with qualification?


Importing System.Process with qualification is fine, thanks!

cheers,
Nicholas — https://ntung.com — CS and Mathematics major @ UC Berkeley
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Felipe Almeida Lessa
On Thu, May 19, 2011 at 3:50 PM, Serguey Zefirov sergu...@gmail.com wrote:
 The solution... I think that some ratings, like used directly by ###
 packages/projects and indirectly by ### would be nice, but not much.

 As for me, I like the diversity of packages. They attack close
 problems from different fronts. They express different ideas and
 views. I like all that.

Regarding the Unicode problem, there is a standard solution today: use
the text package.  Yes, you may use other libraries, but text is the
recommended one.

The problem is that no one coming to Hackage discovers that on Hackage
itself.  You have to dig the Internet to find some blog post telling
you what to do.  And hope that the blog post isn't old.

So we really need a way of raking libraries in Hackage.  We already
have the Haskell Platform, which is really really nice, but the HP
can't embrace everything.  For everything outside HP, a ranking system
is needed.

Cheers! =)

-- 
Felipe.

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Stephen Tetley
Och Mr Coppin

Lisp is a fine language, but all Lisp essays you'll find on the
internet except Richard Gabriel's Worse is Better are absolute tosh.

Read Olin Shiver's introduction to SRE regex notation for an
intelligent contribution to the 6 different libraries problem you
seem to be having, rather than some cargo cultist muddy thinking.

http://www.scsh.net/docu/post/sre.html

By the way, referencing the original article circa half way down -
didn't Mark P. Jones write Gofer and the original Hugs by himself  -
people actually used those rather than Qi.

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Don Stewart
This is classic community trolling behavior, Andrew.

You post something inflammatory, questioning the core value of our
project, without a clear argument about why it article relevant, and
then step away to let a monster thread consume everything, as people
try to work out what your point was, not trying to argue a point, or
other wise participate.

Doing this, year after year, is bad for -cafe@ and bad for the
community, and why I don't use -cafe@ for problem solving anymore.

-- Don

I'm glad my mail reader has a mute button.

On Thu, May 19, 2011 at 12:39 PM, Stephen Tetley
stephen.tet...@gmail.com wrote:
 Och Mr Coppin

 Lisp is a fine language, but all Lisp essays you'll find on the
 internet except Richard Gabriel's Worse is Better are absolute tosh.

 Read Olin Shiver's introduction to SRE regex notation for an
 intelligent contribution to the 6 different libraries problem you
 seem to be having, rather than some cargo cultist muddy thinking.

 http://www.scsh.net/docu/post/sre.html

 By the way, referencing the original article circa half way down -
 didn't Mark P. Jones write Gofer and the original Hugs by himself  -
 people actually used those rather than Qi.

 ___
 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] blaze-builder and FlexibleInstances in code that aims to become part of the Haskell platform

2011-05-19 Thread Simon Meier
Hi Antoine, thanks for your feedback.

2011/5/18 Antoine Latter aslat...@gmail.com:
 On Wed, May 18, 2011 at 12:32 PM, Simon Meier iridc...@gmail.com wrote:
 Hello Haskell-Cafe,





 There are many providers of Writes. Each bounded-length-encoding of a
 standard Haskell value is likely to have a corresponding Write. For
 example, encoding an Int32 as a big-endian, little-endian, and
 host-endian byte-sequence is currently achieved with the following
 three functions.

  writeInt32BE :: Write Int32
  writeInt32LE :: Write Int32
  writeInt32HE :: Write Int32

 I would like to avoid naming all these encodings individually.
 Especially, as the situation becomes worse for more elaborate
 encodings like hexadecimal encodings. There, we encounter encodings
 like the utf8-encoding of the hexadecimal-encoding with lower-case
 letters of an Int32.

  writeInt32HexLowerUtf8 :: Write Int32

 I really don't like that. Therefore, I'm thinking about the following
 solution based on type-classes. We introduce a single typeclass

  class Writable a where
      write :: Write a

 and use a bunch of newtypes to denote our encodings.

  newtype Ascii7   a = Ascii7   { unAscii7   :: a }
  newtype Utf8     a = Utf8     { unUtf8     :: a }
  newtype HexUpper a = HexUpper { unHexUpper :: a }
  newtype HexLower a = HexLower { unHexLower :: a }
  ...

 Assuming FlexibleInstnaces, we can write encodings like the above
 hex-encoding as instances

  instance Write (Utf8 (HexLower Int32)) where
    write = ...

 This composes rather nicely and allows the implementations to exploit
 special properties of the involved data. For example, if we also had a
 HTML escaping marker

  newtype Html     a = Html     { unHtml     :: a }

 Then, the instance

  instance Write (Utf8 (HTML (HexLower Int32))) where
    write (Utf8 (HTML (HexLower i))) = write (Utf8 (HexLower i))

 If I were authoring the above code, I don't see why that code is any
 easier to write or easier to read than:

 urf8HtmlHexLower i = utf8HexLower i

 And if I were using the encoding functions, I would much prefer to see:

 urf8HtmlHexLower magicNumber

 In my code, instead of:

 write $ Utf8 $ HTML $ HexLower magicNumber

 In addition, this would be difficult for me as a developer using the
 proposed library, because I would have no way to know which
 combinations of newtypes are valid from reading the haddocks.

 Maybe I'm missing something fundamental, but this approach seems more
 cumbersome to me as a library author (more boilerplate) and as the
 user of the library (less clarity in the docs and in the resultant
 code).

Hmm, that's a valid point you raise here. Especially, the
documentation issue bothers me.

The core problem that drove me towards this solution is the abundance
of different IntX and WordX types. Each of them requiring a separate
Write for big-endian, little-endian, host-endian, lower-case-hex, and
uper-case-hex encodings; i.e., currently, there are

int8BE   :: Write Int8
int16BE :: Write Int16
int32BE :: Write Int32
...
hexLowerInt8 :: Write Int8
...

and so on. As you can see
(http://hackage.haskell.org/packages/archive/blaze-builder/0.3.0.1/doc/html/Blaze-ByteString-Builder-Word.html)
this approach clutters the public API quite a bit. Hence, I'm thinking
of using a separate type-class for each encoding; i.e.,

  class BigEndian a where
bigEndian :: Write a

This collapses the big-endian encodings of all 10 bounded-size (signed
and unsigned) integer types under a single name with a well-defined
semantics. Moreover, it's standard Haskell 98. For the hex-encodings,
I'm thinking about providing type-classes

  class HexLower a where
hexLower :: Write a

  class HexLowerNoLead a where
hexLowerNoLead :: Write a

  ...

for ASCII encoding and each of the standard Unicode encodings in a
separate module. The user can then select the right ones using
qualified imports. In most cases, he won't even need qualification, as
mixing different character encodings is seldomly used.

What do you think about such an interface? Is there another catch
hidden, I'm not seeing? BTW, note that Writes are a pure compile time
abstraction and are thought to be completely inlined. In typical, uses
cases there's no efficiency overhead stemming from these typeclasses.

best regards,
Simon

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Andrew Coppin

On 19/05/2011 07:56 PM, Gilberto Garcia wrote:

I think what Andrew meant is that it's not a good idea to have big
pile of different implementations of the same library, and all trying
to solve the very same problem.


I'm glad somebody understood what I was trying to get at.

I'm not saying that we shouldn't ever have more than one library 
tackling the same problem. I'm just saying that when people say we have 
multiple libraries competing to solve this problem, and that's 
*great*... well, not necessarily, no. Obviously there's room for 
finding out what the best way to solve the problem is, but ultimately 
the ideal is to end up with one library that solves the problem well, 
which everybody can use.


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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Andrew Coppin

On 19/05/2011 08:39 PM, Stephen Tetley wrote:

Och Mr Coppin

Lisp is a fine language, but all Lisp essays you'll find on the
internet except Richard Gabriel's Worse is Better are absolute tosh.


This wasn't an attempt to bash Lisp.

This is about all those people who think having multiple libraries which 
only solve half the problem is somehow a good thing.


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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Andrew Coppin

On 19/05/2011 08:58 PM, Don Stewart wrote:

This is classic community trolling behavior, Andrew.


And publicly calling somebody a troll isn't trolling behaviour?

I'm going to answer the rest of this off-list. I'm sure nobody else 
wants to hear it.


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


Re: [Haskell-cafe] Trying to return a map from State monad

2011-05-19 Thread michael rice
OK. Again, not sure what going on here. Pattern looks OK to me.
Michael
=
import Control.Monad.Stateimport Data.Map
type Prefix = (String,String)type GeneratorState = State ((Map Prefix 
[String]),Prefix,[String])

non_word = \n
f key new old = new ++ old 
buildMap :: GeneratorState (Map Prefix [String])buildMap = do 
(mp,(pfx1,pfx2),all@(w1:words)) - get              if (Prelude.null all)       
         then  {- No more words. Return final map (adding non_word for prefix). 
-}                  return (insertWithKey' f (pfx1,pfx2) [non_word] mp)         
       else do {- Add word to map at prefix. Continue. -}                  put 
(insertWithKey' f (pfx1,pfx2) [w1] mp, (pfx2,w1), words)                  
buildMap
=
*Main :r[1 of 1] Compiling Main             ( markov3.hs, interpreted )Ok, 
modules loaded: Main.*Main fst $ runState buildMap (singleton (\n,\n) [], 
(\n,\n), [I,am,lost.])fromList *** Exception: Pattern match failure 
in do expression at markov3.hs:13:14-44

--- On Thu, 5/19/11, michael rice nowg...@yahoo.com wrote:

From: michael rice nowg...@yahoo.com
Subject: Re: [Haskell-cafe] Trying to return a map from State monad
To: Thedward Blevins thedw...@barsoom.net
Cc: haskell-cafe@haskell.org
Date: Thursday, May 19, 2011, 12:41 PM

Ok, I see I left out the State word.
Should be: type GeneratorState = State (Map Prefix [String],Prefix,[String])
Thanks,
Michael

--- On Thu, 5/19/11, Thedward Blevins thedw...@barsoom.net wrote:

From: Thedward Blevins thedw...@barsoom.net
Subject: Re: [Haskell-cafe] Trying to return a map from State monad
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Thursday, May 19, 2011, 12:22 PM

On Thu, May 19, 2011 at 11:03, michael rice nowg...@yahoo.com wrote:
 type GeneratorState = (Map Prefix [String],Prefix,[String])

 buildMap :: GeneratorState (Map Prefix [String])

You are trying to use a type alias (GeneratorState) as a type constructor.

There may be other problems, but that leaps out.

-Inline Attachment Follows-

___
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] The Lisp Curse

2011-05-19 Thread vagif . verdi
Andrew, you are being non constructive.

You are saying We should.
Who we, Andrew ? Who are you referring to ?
The developers who created those six different unicode libraries are not united 
under any umbrella you can call we.

The reason those six libraries existis is NOT because some mysterious secret 
we commitee decided to have six incompatible libraries.

And the maintainers of hackage has better things to do than to police and make 
arbitrary decisions what should or should not be allowed to hackage.

Also hackage is NOT a standard library, just like SourceForge or Github is not 
a standard library. It's just a hosting for haskell libraries.

If you want someone tell you what to use, there's an effort in that direction: 
haskell platform. And their attitue is constructive. They don't demand that 
we (whoever that is) do or do not do something. They compile their own set 
of libraries and announce about their existence.

Go lobby them to include one blessed unicode library.


On Thursday, May 19, 2011 01:20:50 PM Andrew Coppin wrote:
 On 19/05/2011 08:39 PM, Stephen Tetley wrote:
  Och Mr Coppin
  
  Lisp is a fine language, but all Lisp essays you'll find on the
  internet except Richard Gabriel's Worse is Better are absolute tosh.
 
 This wasn't an attempt to bash Lisp.
 
 This is about all those people who think having multiple libraries which
 only solve half the problem is somehow a good thing.
 
 ___
 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] blaze-builder and FlexibleInstances in code that aims to become part of the Haskell platform

2011-05-19 Thread Simon Meier
Hi Johan,

thanks for the extensive and motivating feedback.

2011/5/19 Johan Tibell johan.tib...@gmail.com:
 On Wed, May 18, 2011 at 7:32 PM, Simon Meier iridc...@gmail.com wrote:
 In fact, one of my current goals with this work is to polish it such
 that it can be integrated into the 'bytestring' library.

 We should definitely add a builder monoid in the bytestring package.

 Since Write mentions IO, I thought I should point out that we need to
 separate any code that mentions IO from the the code that doesn't
 (i.e. the pure Builder API). The use of IO is an implementation detail
 in bytestring. We should follow the existing bytestring pattern and
 put any code that mentions IO in e.g.
 Data.ByteString.Lazy.Builder.Internal. This allows the few people who
 need to access the internals to do so while making it clear that these
 are in fact internals. Long term we'd like to switch bytestring over
 from ForeignPtr to ByteArray#, if possible. There are currently some
 technical obstacles to such a switch, but factoring out the IO code at
 least makes it somewhat easier if we ever get around to switching.

 Avoiding IO in the main API means that the main builder type must not
 mention IO (or things related to IO, such as Storable).

I completely agree with you. The system-io-write library [1] and the
bytestring fork [2] I'm working on provide separate interfaces for
standard and expert users. The naming of the system-io-write library
is tentative and can be adapted once it's place is clear.

 The core principle used to tackle (1) is avoiding intermediate data
 structures.  The core abstraction used is the one of a Write (see [1]
 for the corresponding library.)

  data Write a = Write Int (a - Ptr Word8 - IO (Ptr Word8))

 A value `Write bound io :: Write a` denotes an encoding scheme for
 values of type `a` that uses at most `bound` bytes space. Given a
 values `x :: a` and a pointer `po` to the next free byte `io x po`
 encodes `x` to memory starting from `po` and returns the pointer to
 the next free byte after the encoding of `x`.

 In most cases Writes are used as an abstract datatype. They serve as
 an interface between implementors of the low-level bit-twiddling
 required to efficiently implement encodings like UTF-8 or Base16 and
 the providers of efficient traversal functions through streams of
 Haskell values. Hence, typical users of Writes are functions like

  fromWrite          :: Write a - a - Builder
  fromWriteList      :: Write a - [a] - Builder
  fromWriteUnfoldr   :: Write b - (a - Maybe (b, a)) - a - Builder
  mapWriteByteString :: Write Word8 - S.ByteString - Builder

 We want to allow users to efficiently create new builders, for their
 own data type. This is crucial as the bytestring package cannot
 provide efficient builders for every possible type, as it would have
 to depend on most of Hackage (i.e. on all packages that define types
 that we want efficient builders for) to do so. Allowing the user to
 get hold of the underlying buffer in a controlled way makes the
 builder extensible. This is good.

 Write achieves this separation, but it has some costs which I'm not
 entirely comfortable with.

 First, it leads to lots of API duplication. For every type (e.g. Word)
 we want to be able serialize we have two morally identical functions

    writeWordhost :: Word - Write
    fromWordhost :: Word - Builder

 in the API, where the latter simply calls the former and does some
 additional wrapping.

Yes, I agree with this duplication. I'll explain below what we gain
from it. Note that I factored out the whole Write stuff into its own
library (system-io-write) for the bytestring integration. Therefore,
an end-user of bytestring will only see the Builder versions except
he's doing more low-level stuff to gain some extra performance.

 See 
 http://hackage.haskell.org/packages/archive/blaze-builder/0.3.0.1/doc/html/Blaze-ByteString-Builder-Word.html
 for examples.

 Simon, is the reason for this duplication this comment on top of
 Blaze.ByteString.Builder.Word?

    Note that for serializing a three tuple (x,y,z) of bytes (or other
    word values) you should use the expression

        fromWrite $ writeWord8 x `mappend` writeWord8 y `mappend` writeWord z

    instead of

        fromWord8 x `mappend` fromWord8 y `mappend` fromWord z

    The first expression will result in a single atomic write of three
    bytes, while the second expression will check for each byte, if
    there is free space left in the output buffer. Coalescing these
    checks can improve performance quite a bit, as long as you use it
    sensibly.

That's one of the reasons, but not the main one. The core reason is
that Write's provide
an interface between implementors of the low-level bit-twiddling
required to efficiently implement encodings like UTF-8 or Base16 and
the providers of efficient traversal functions through (streams of)
Haskell values. For simple traversals like

  fromWrite          :: Write a - a - 

Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Stephen Tetley
On 19 May 2011 21:20, Andrew Coppin andrewcop...@btinternet.com wrote:

 This is about all those people who think having multiple libraries which
 only solve half the problem is somehow a good thing.

Och (number 2)

Those people are the Straw Men - you can wave at them from your car
window when you pass them as they stand in farmer's fields, though it
is not out of rudeness that they do not wave back. Alas they are
really made of straw.

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Andrew Coppin

On 19/05/2011 09:34 PM, vagif.ve...@gmail.com wrote:

Andrew, you are being non constructive.


It seems I'm being misunderstood.

Some people seem to hold the opinion that more libraries = better. I'm 
trying to voice the opinion that there is such a thing as too many 
libraries. The article I linked to explains part of why this is the 
case, in a better way than I've been able to phrase it myself.


I'm not trying to say OMG, the way it is now completely sucks! I'm not 
trying to say you must do X right now! I'm just trying to put forward 
an opinion. The opinion that having too many libraries can be a problem, 
which some people don't seem to agree with. (Obviously it isn't *always* 
bad, I'm just saying that sometimes it can be.)


That's all I was trying to say.

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


Re: [Haskell-cafe] Trying to return a map from State monad

2011-05-19 Thread aditya siram
The problem is that the all@(w1:words) pattern-match fails when all is
empty. The quick and dirty fix is:
import Control.Monad.State
import Data.Map
import Debug.Trace

type Prefix = (String,String)
type GeneratorState = State ((Map Prefix [String]),Prefix,[String])


non_word = \n

f key new old = new ++ old

buildMap :: GeneratorState (Map Prefix [String])
buildMap = do (mp,(pfx1,pfx2),all) - get
  if (Prelude.null all)
then  {- No more words. Return final map (adding
non_word for prefix). -}
  return (insertWithKey' f (pfx1,pfx2) [non_word] mp)
else do {- Add word to map at prefix. Continue. -}
  put (insertWithKey' f (pfx1,pfx2) [head all] mp,
(pfx2,head all), tail all)
  buildMap

*Main  fst $ runState buildMap (singleton (\n,\n) [], (\n,\n),
[I,am,lost.])
fromList
[((\n,\n),[I]),((\n,I),[am]),((I,am),[lost.]),((am,lost.),[\n])]

A better one would be to write a helper function that correctly pattern
matched on the list.

-deech




On Thu, May 19, 2011 at 3:30 PM, michael rice nowg...@yahoo.com wrote:

 OK. Again, not sure what going on here. Pattern looks OK to me.

 Michael

 =

 import Control.Monad.State
 import Data.Map

 type Prefix = (String,String)
 type GeneratorState = State ((Map Prefix [String]),Prefix,[String])


 non_word = \n

 f key new old = new ++ old

 buildMap :: GeneratorState (Map Prefix [String])
 buildMap = do (mp,(pfx1,pfx2),all@(w1:words)) - get
   if (Prelude.null all)
 then  {- No more words. Return final map (adding non_word
 for prefix). -}
   return (insertWithKey' f (pfx1,pfx2) [non_word] mp)
 else do {- Add word to map at prefix. Continue. -}
   put (insertWithKey' f (pfx1,pfx2) [w1] mp, (pfx2,w1),
 words)
   buildMap

 =

 *Main :r
 [1 of 1] Compiling Main ( markov3.hs, interpreted )
 Ok, modules loaded: Main.
 *Main fst $ runState buildMap (singleton (\n,\n) [], (\n,\n),
 [I,am,lost.])
 fromList *** Exception: Pattern match failure in do expression at
 markov3.hs:13:14-44


 --- On *Thu, 5/19/11, michael rice nowg...@yahoo.com* wrote:


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

 Subject: Re: [Haskell-cafe] Trying to return a map from State monad
 To: Thedward Blevins thedw...@barsoom.net

 Cc: haskell-cafe@haskell.org
 Date: Thursday, May 19, 2011, 12:41 PM


 Ok, I see I left out the State word.

 Should be:
 type GeneratorState = State (Map Prefix [String],Prefix,[String])

 Thanks,

 Michael


 --- On *Thu, 5/19/11, Thedward Blevins thedw...@barsoom.net* wrote:


 From: Thedward Blevins thedw...@barsoom.net
 Subject: Re: [Haskell-cafe] Trying to return a map from State monad
 To: michael rice nowg...@yahoo.com
 Cc: haskell-cafe@haskell.org
 Date: Thursday, May 19, 2011, 12:22 PM

 On Thu, May 19, 2011 at 11:03, michael rice nowg...@yahoo.com wrote:
  type GeneratorState = (Map Prefix [String],Prefix,[String])

  buildMap :: GeneratorState (Map Prefix [String])

 You are trying to use a type alias (GeneratorState) as a type constructor.

 There may be other problems, but that leaps out.


 -Inline Attachment Follows-


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org http://mc/compose?to=Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


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


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


Re: [Haskell-cafe] Trying to return a map from State monad

2011-05-19 Thread michael rice
A laugh a minute. I though of that and tried it but got the same response 
(forgetting to :r my source) before rerunning. Time for a break.
Thanks!
Michael 
--- On Thu, 5/19/11, aditya siram aditya.si...@gmail.com wrote:

From: aditya siram aditya.si...@gmail.com
Subject: Re: [Haskell-cafe] Trying to return a map from State monad
To: michael rice nowg...@yahoo.com
Cc: Thedward Blevins thedw...@barsoom.net, haskell-cafe@haskell.org
Date: Thursday, May 19, 2011, 4:57 PM

The problem is that the all@(w1:words) pattern-match fails when all is 
empty. The quick and dirty fix is:
    import Control.Monad.State
    import Data.Map
    import Debug.Trace
    

    type Prefix = (String,String)
    type GeneratorState = State ((Map Prefix [String]),Prefix,[String])
    
    
    non_word = \n
    
    f key new old = new ++ old 
    
    buildMap :: GeneratorState (Map Prefix [String])

    buildMap = do (mp,(pfx1,pfx2),all) - get
  if (Prelude.null all)
    then  {- No more words. Return final map (adding non_word 
for prefix). -}
  return (insertWithKey' f (pfx1,pfx2) [non_word] mp)

    else do {- Add word to map at prefix. Continue. -}
  put (insertWithKey' f (pfx1,pfx2) [head all] mp, 
(pfx2,head all), tail all)
  buildMap

*Main  fst $ runState buildMap (singleton (\n,\n) [], (\n,\n), 
[I,am,lost.])

fromList 
[((\n,\n),[I]),((\n,I),[am]),((I,am),[lost.]),((am,lost.),[\n])]


A better one would be to write a helper function that correctly pattern matched 
on the list.

-deech




On Thu, May 19, 2011 at 3:30 PM, michael rice nowg...@yahoo.com wrote:


OK. Again, not sure what going on here. Pattern looks OK to me.
Michael

=
import Control.Monad.State
import Data.Map
type Prefix =
 (String,String)type GeneratorState = State ((Map Prefix 
[String]),Prefix,[String])


non_word = \n
f key new old = new ++ old 

buildMap :: GeneratorState (Map Prefix [String])buildMap = do 
(mp,(pfx1,pfx2),all@(w1:words)) - get
 
             if (Prelude.null all)                then  {- No more words. 
Return final map (adding non_word for prefix). -}                  return 
(insertWithKey' f (pfx1,pfx2) [non_word] mp)
                else do {- Add word to map at prefix. Continue. -}              
    put (insertWithKey' f (pfx1,pfx2) [w1] mp, (pfx2,w1), words)
                 
 buildMap
=
*Main :r
[1 of 1] Compiling Main             ( markov3.hs, interpreted )Ok, modules 
loaded: Main.*Main fst $ runState buildMap (singleton (\n,\n) [], 
(\n,\n), [I,am,lost.])
fromList *** Exception: Pattern match failure in do expression at 
markov3.hs:13:14-44

--- On Thu, 5/19/11, michael rice nowg...@yahoo.com wrote:


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

Subject: Re: [Haskell-cafe] Trying to return a map from State monad
To: Thedward Blevins thedw...@barsoom.net
Cc: haskell-cafe@haskell.org

Date: Thursday, May 19, 2011, 12:41 PM

Ok, I see I left out the State word.

Should be: type GeneratorState = State (Map Prefix
 [String],Prefix,[String])
Thanks,
Michael

--- On Thu, 5/19/11, Thedward Blevins thedw...@barsoom.net wrote:


From: Thedward Blevins thedw...@barsoom.net
Subject: Re: [Haskell-cafe] Trying to return a map from State monad

To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Thursday, May 19, 2011, 12:22 PM


On Thu, May 19, 2011 at 11:03, michael rice nowg...@yahoo.com wrote:
 type GeneratorState = (Map Prefix [String],Prefix,[String])

 buildMap :: GeneratorState (Map Prefix [String])


You are trying to use a type alias (GeneratorState) as a type constructor.

There may be other problems, but that leaps
 out.

-Inline Attachment Follows-

___
Haskell-Cafe mailing list

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


___

Haskell-Cafe mailing list

Haskell-Cafe@haskell.org

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




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


[Haskell-cafe] Reverse Show instance

2011-05-19 Thread Andrew Coppin

  Cannot deduce (Show x) from context (Show (x, y)).
  Cannot deduce (Show y) from context (Show (x, y)).

Um... seriously?

From Prelude, we have

  Show x, Show y = Show (x, y)

So clearly it works in the forward direction. But apparently not in the 
reverse direction.


Is this a bug or a feature? (I.e., is there some obscure possibility I 
haven't thought of which means that doing the reverse inference would be 
incorrect?)


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


Re: [Haskell-cafe] Reverse Show instance

2011-05-19 Thread Artyom Kazak

And I can declare an instance for (x, y) which does NOT implies (Show x):

instance Show (x, y) where
  show _ = I'm tuple! Hooray!


Andrew Coppin andrewcop...@btinternet.com писал(а) в своём письме Fri,  
20 May 2011 00:08:27 +0300:



   Cannot deduce (Show x) from context (Show (x, y)).
   Cannot deduce (Show y) from context (Show (x, y)).

Um... seriously?

 From Prelude, we have

   Show x, Show y = Show (x, y)

So clearly it works in the forward direction. But apparently not in the  
reverse direction.


Is this a bug or a feature? (I.e., is there some obscure possibility I  
haven't thought of which means that doing the reverse inference would be  
incorrect?)


___
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] Reverse Show instance

2011-05-19 Thread Andrew Coppin

On 19/05/2011 10:11 PM, Artyom Kazak wrote:

And I can declare an instance for (x, y) which does NOT implies (Show x):

instance Show (x, y) where
show _ = I'm tuple! Hooray!


Ah. So it's a feature.

Fortunately I refactored the program where this came up, so it's no 
longer an issue. I just wanted to see whether or not it was a bug.


PS. Wouldn't such an instance require FlexibleContexts or something?

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


Re: [Haskell-cafe] Reverse Show instance

2011-05-19 Thread Markus Läll
If you have nested type, then it usually makes sense to have Show defined
for the inside types, too, but it's not a requirement. Technically, only
when you call 'show' for something in the data type you are defining Show
for, *then* you need a Show instance defined for that inside-type.

On Fri, May 20, 2011 at 12:15 AM, Andrew Coppin andrewcop...@btinternet.com
 wrote:

 On 19/05/2011 10:11 PM, Artyom Kazak wrote:

 And I can declare an instance for (x, y) which does NOT implies (Show x):

 instance Show (x, y) where
 show _ = I'm tuple! Hooray!


 Ah. So it's a feature.

 Fortunately I refactored the program where this came up, so it's no longer
 an issue. I just wanted to see whether or not it was a bug.

 PS. Wouldn't such an instance require FlexibleContexts or something?


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




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


Re: [Haskell-cafe] Reverse Show instance

2011-05-19 Thread Daniel Fischer
On Thursday 19 May 2011 23:15:06, Andrew Coppin wrote:
 On 19/05/2011 10:11 PM, Artyom Kazak wrote:
  And I can declare an instance for (x, y) which does NOT implies (Show
  x):
  
  instance Show (x, y) where
  show _ = I'm tuple! Hooray!
 
 Ah. So it's a feature.
 
 Fortunately I refactored the program where this came up, so it's no
 longer an issue. I just wanted to see whether or not it was a bug.
 
 PS. Wouldn't such an instance require FlexibleContexts or something?


No, the instance head is a type constructor applied to two distinct type 
variables, it's a perfectly valid H98 instance declaration.

It won't be accepted though, because there is already

instance (Show x, Show y) = Show (x,y) where ...

I think basically the only way to make GHC accept the above instance 
involves NoImplicitPrelude (but I may be wrong).

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Julian Porter
  ultimately the ideal is to end up with one library that solves the problem 
 well, which everybody can use.
 
 
 Nonsense.  One library that everyone can use with either end up being so small 
in functionality that it's actually useless, or so general that either it 
requires tons and tons of boilerplate just to use it at all, or it's really 
about eight libraries rolled into one and so impossible to find your way 
around.  Whichever, it's not good.  The sweet spot is at the point of maximum 
tension between generality and simplicity.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Ketil Malde
Andrew Coppin andrewcop...@btinternet.com writes:

 I'm trying to voice the opinion that there is such a thing as too many
 libraries. The article I linked to explains part of why this is the
 case, in a better way than I've been able to phrase it myself.

I don't think so, the article seems to talk more about social problems
among lisp users, which it - at least in part - ascribes to the technical
prowess of the language.

I don't think the article makes its point very well, though. For
instance, it uses object orientation as an example, but CLOS is fairly
standard in Lisp, I believe, and the author had to turn to Scheme for
his examples.  The problem again seems to be more social (the lack of an
active committee to do standardizing) than technical.

 The opinion that having too many libraries can be
 a problem, which some people don't seem to agree with.

I don't see how the number of available libraries is a problem in
itself, but it would be nice if hackage or some other resource provided
more help in recommending which library to try first.  We do have
standardization efforts, committees bringing the language forward and an
inclusive and collaborative community.

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

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread aditya siram
I wonder if it would be useful to be able to download and use only necessary
modules from Hackage. This way if someone writes, say a superior XML parsing
API, and someone else has better generating API, the user can pull just
those modules , write the glue and have the best of both worlds.

On the upside this would:
1. Make for a smaller local cabal repository.
2. Mitigate the problem of having to compile a package that has
functionality you don't need. MissingH [1] is a good example.
3. Allow you to continue working even if one of the modules doesn't compile.
I recently ran into this with liboleg [2] where I only wanted Control.CCCXe,
but couldn't cabal install it on my system because one of the other
modules failed to compile.

-deech

[1] http://hackage.haskell.org/package/MissingH-1.1.0.3
[2] http://hackage.haskell.org/package/liboleg

On Thu, May 19, 2011 at 4:30 PM, Julian Porter
julian.por...@porternet.orgwrote:

   ultimately the ideal is to end up with one library that solves the
 problem well, which everybody can use.
 
 
  Nonsense.  One library that everyone can use with either end up being so
 small in functionality that it's actually useless, or so general that either
 it requires tons and tons of boilerplate just to use it at all, or it's
 really about eight libraries rolled into one and so impossible to find your
 way around.  Whichever, it's not good.  The sweet spot is at the point of
 maximum tension between generality and simplicity.
 ___
 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] blaze-builder and FlexibleInstances in code that aims to become part of the Haskell platform

2011-05-19 Thread Antoine Latter
On Thu, May 19, 2011 at 3:06 PM, Simon Meier iridc...@gmail.com wrote:

 The core problem that drove me towards this solution is the abundance
 of different IntX and WordX types. Each of them requiring a separate
 Write for big-endian, little-endian, host-endian, lower-case-hex, and
 uper-case-hex encodings; i.e., currently, there are

 int8BE   :: Write Int8
 int16BE :: Write Int16
 int32BE :: Write Int32
 ...
 hexLowerInt8 :: Write Int8
 ...

 and so on. As you can see
 (http://hackage.haskell.org/packages/archive/blaze-builder/0.3.0.1/doc/html/Blaze-ByteString-Builder-Word.html)
 this approach clutters the public API quite a bit. Hence, I'm thinking
 of using a separate type-class for each encoding; i.e.,


If Johan's work on Data.Binary and rewrite rules works out, then it
would cut the exposed API in half, which helps.

We could then use the module and package system to further keep the
API clean, with builders which output a specific encoding could live
in separate modules. This could also keep the names of the functions
short, as well.

That would require coming up with logical divisions for the functions
you're creating, and I don't understand the big picture enough to help
with that.

  class BigEndian a where
    bigEndian :: Write a

 This collapses the big-endian encodings of all 10 bounded-size (signed
 and unsigned) integer types under a single name with a well-defined
 semantics. Moreover, it's standard Haskell 98. For the hex-encodings,
 I'm thinking about providing type-classes

  class HexLower a where
    hexLower :: Write a

  class HexLowerNoLead a where
    hexLowerNoLead :: Write a

  ...

 for ASCII encoding and each of the standard Unicode encodings in a
 separate module. The user can then select the right ones using
 qualified imports. In most cases, he won't even need qualification, as
 mixing different character encodings is seldomly used.


I think we may be at cross-purposes here, and might not even be
discussing the same thing - I would imagine that any sort of 'Builder'
type included in the bytestring package would only provide the core
combinators for packing data into low-level binary formats, so
discussions about text encoding issues, converting to hexidecimal and
Html escaping are going above my head.

This seems like what the 'text' package was written for - to separate
out the construction of textual data from choosing its encoding.

Are there use-cases where the 'text' package is too slow for this sort
of approach?

Take care,
Antoine

 What do you think about such an interface? Is there another catch
 hidden, I'm not seeing? BTW, note that Writes are a pure compile time
 abstraction and are thought to be completely inlined. In typical, uses
 cases there's no efficiency overhead stemming from these typeclasses.

 best regards,
 Simon


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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Daniel Peebles
The way I understand it, you're saying not that we shouldn't be doing it
this way (since it isn't centrally managed, it's the only possible way), but
that we shouldn't be bragging (for lack of a better word) that we have
lots of libraries that do a specific thing. Or if not that, then at least
that it isn't a clear win.

I agree that from an end-user's perspective it isn't always a clear win, but
I do think that having a bunch of libraries (even ones that do the same
thing) an indicator of a healthy, active, and enthusiastic community. Sure,
it's decentralized and people will often duplicate effort, but different
variations on the same idea can also help explore the design space and will
reveal to everyone interested what works and what doesn't.

But yeah, if you want to do X and you encounter 15 libraries that do X and
can't find a clear consensus on what's best, I can understand why that might
be frustrating. I don't think there's really a clear solution to that
though, other than gently encouraging collaboration and scoping out of
existing work before starting new work. But people generally hate working
with other people's code, so I doubt that'll have much of an effect :)

Dan

On Thu, May 19, 2011 at 4:56 PM, Andrew Coppin
andrewcop...@btinternet.comwrote:

 On 19/05/2011 09:34 PM, vagif.ve...@gmail.com wrote:

 Andrew, you are being non constructive.


 It seems I'm being misunderstood.

 Some people seem to hold the opinion that more libraries = better. I'm
 trying to voice the opinion that there is such a thing as too many
 libraries. The article I linked to explains part of why this is the case, in
 a better way than I've been able to phrase it myself.

 I'm not trying to say OMG, the way it is now completely sucks! I'm not
 trying to say you must do X right now! I'm just trying to put forward an
 opinion. The opinion that having too many libraries can be a problem, which
 some people don't seem to agree with. (Obviously it isn't *always* bad, I'm
 just saying that sometimes it can be.)

 That's all I was trying to say.


 ___
 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] blaze-builder and FlexibleInstances in code that aims to become part of the Haskell platform

2011-05-19 Thread Henning Thielemann
Simon Meier schrieb:

 There are many providers of Writes. Each bounded-length-encoding of a
 standard Haskell value is likely to have a corresponding Write. For
 example, encoding an Int32 as a big-endian, little-endian, and
 host-endian byte-sequence is currently achieved with the following
 three functions.
 
   writeInt32BE :: Write Int32
   writeInt32LE :: Write Int32
   writeInt32HE :: Write Int32
 
 I would like to avoid naming all these encodings individually.

Maybe this one helps:
http://hackage.haskell.org/packages/archive/storable-endian/0.2.4/doc/html/Data-Storable-Endian.html
?

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread austin seipp
I too am not all that concerned about the library proliferation, and I
think such work can definitely help find the best design for certain
abstractions. There are no less than 3 iteratee libraries - 4
including liboleg's original IterateeM formulation - and a number of
FRP implementations as well, but part of that is because we haven't
found the best designs for such things yet. Doing that will take time
and effort on the part of the community, whether there's 3 competing
libraries or 30.

In the case of Unicode, I think the community has clearly spoken in
its adoption of the `text` package into the Platform, as well as it
being one of the most depended on hackage packages. Certainly the
platform doesn't recommend a 'blessed' package for every need. JSON is
a simple example, and there are many various JSON implementations on
Hackage. Outside of the platform, I think there should definitely be a
better way to communicate to users what library might be best. I don't
know how that would look - Hackage 2 will have commenting and reverse
dependencies I think, but when that future hackage will rise is not
clear.

One thing is for certain: in the Haskell ecosystem, if your code does
not exist on Hackage, and *especially* if it does not use Cabal,
realistically speaking, it is dead as far as the larger community is
concerned (the exception being GHC itself, perhaps. Even gtk2hs - who
was one of the biggest outliers for a long time, now is cabalized.) I
think I would ultimately rather encourage people to submit code - even
if it is small or perhaps duplicate. At least give it and its ideas
the chance to survive, be used and talked about, and die if not -
rather than resign it to such a fate prematurely.

On Thu, May 19, 2011 at 5:00 PM, Daniel Peebles pumpkin...@gmail.com wrote:
 The way I understand it, you're saying not that we shouldn't be doing it
 this way (since it isn't centrally managed, it's the only possible way), but
 that we shouldn't be bragging (for lack of a better word) that we have
 lots of libraries that do a specific thing. Or if not that, then at least
 that it isn't a clear win.
 I agree that from an end-user's perspective it isn't always a clear win, but
 I do think that having a bunch of libraries (even ones that do the same
 thing) an indicator of a healthy, active, and enthusiastic community. Sure,
 it's decentralized and people will often duplicate effort, but different
 variations on the same idea can also help explore the design space and will
 reveal to everyone interested what works and what doesn't.
 But yeah, if you want to do X and you encounter 15 libraries that do X and
 can't find a clear consensus on what's best, I can understand why that might
 be frustrating. I don't think there's really a clear solution to that
 though, other than gently encouraging collaboration and scoping out of
 existing work before starting new work. But people generally hate working
 with other people's code, so I doubt that'll have much of an effect :)
 Dan

 On Thu, May 19, 2011 at 4:56 PM, Andrew Coppin andrewcop...@btinternet.com
 wrote:

 On 19/05/2011 09:34 PM, vagif.ve...@gmail.com wrote:

 Andrew, you are being non constructive.

 It seems I'm being misunderstood.

 Some people seem to hold the opinion that more libraries = better. I'm
 trying to voice the opinion that there is such a thing as too many
 libraries. The article I linked to explains part of why this is the case, in
 a better way than I've been able to phrase it myself.

 I'm not trying to say OMG, the way it is now completely sucks! I'm not
 trying to say you must do X right now! I'm just trying to put forward an
 opinion. The opinion that having too many libraries can be a problem, which
 some people don't seem to agree with. (Obviously it isn't *always* bad, I'm
 just saying that sometimes it can be.)

 That's all I was trying to say.

 ___
 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





-- 
Regards,
Austin

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread David Leimbach
See the Haskell Platform.   

Sent from my iPhone

On May 19, 2011, at 1:56 PM, Andrew Coppin andrewcop...@btinternet.com wrote:

 On 19/05/2011 09:34 PM, vagif.ve...@gmail.com wrote:
 Andrew, you are being non constructive.
 
 It seems I'm being misunderstood.
 
 Some people seem to hold the opinion that more libraries = better. I'm trying 
 to voice the opinion that there is such a thing as too many libraries. The 
 article I linked to explains part of why this is the case, in a better way 
 than I've been able to phrase it myself.
 
 I'm not trying to say OMG, the way it is now completely sucks! I'm not 
 trying to say you must do X right now! I'm just trying to put forward an 
 opinion. The opinion that having too many libraries can be a problem, which 
 some people don't seem to agree with. (Obviously it isn't *always* bad, I'm 
 just saying that sometimes it can be.)
 
 That's all I was trying to say.
 
 ___
 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] blaze-builder and FlexibleInstances in code that aims to become part of the Haskell platform

2011-05-19 Thread Bas van Dijk
On 19 May 2011 10:53, Johan Tibell johan.tib...@gmail.com wrote:
 Long term we'd like to switch bytestring over
 from ForeignPtr to ByteArray#, if possible. There are currently some
 technical obstacles to such a switch

BTW I'm working with Roman Leshchinskiy to create the
vector-bytestring package which provides:
type ByteString = Data.Vector.Storable.Vector Word8
and exports the same API as the bytestring package (no support for
lazy bytestrings yet)

A storable vector still uses a ForeignPtr but maybe this will make the
switch to unboxed Vectors (which use ByteArray#) easier.

Expect some code to be up somewhere next week.

Bas

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


Re: [Haskell-cafe] blaze-builder and FlexibleInstances in code that aims to become part of the Haskell platform

2011-05-19 Thread wren ng thornton

On 5/19/11 5:51 PM, Antoine Latter wrote:

On Thu, May 19, 2011 at 3:06 PM, Simon Meieriridc...@gmail.com  wrote:


The core problem that drove me towards this solution is the abundance
of different IntX and WordX types. Each of them requiring a separate
Write for big-endian, little-endian, host-endian, lower-case-hex, and
uper-case-hex encodings; i.e., currently, there are

int8BE   :: Write Int8
int16BE :: Write Int16
int32BE :: Write Int32
...
hexLowerInt8 :: Write Int8
...

and so on. As you can see
(http://hackage.haskell.org/packages/archive/blaze-builder/0.3.0.1/doc/html/Blaze-ByteString-Builder-Word.html)
this approach clutters the public API quite a bit. Hence, I'm thinking
of using a separate type-class for each encoding; i.e.,


It seems to me that a better way of handling this would be to explicitly 
define an ADT (or type-level equivalent) for naming the different format 
options. That is, something like this:


data Endianness = BE | LE | HE
data Radix  = Binary | Octal | Decimal | Hexadecimal
...
data WIFormat = WIFormat
{ endianness :: {-# UNPACK #-} !Endianness
, radix  :: {-# UNPACK #-} !Radix
...}
class WriteWI a where
writeWI :: WIFormat - Write a

If you're sure that you can get rid of the typeclass overhead, then you 
should be able to get rid of the case analysis on the ADT as well (by 
making sure to always use writeWI fully saturated). But this way, you 
only need to deal with one class and it's obvious how to extend it (as 
opposed to your newtype solution where it's not clear whether the order 
of newtype wrapping matters, etc).


Of course, I'm not advocating that specific ADT for encoding format 
types. For example, it's only in decimal format where there's any 
difference between Word* and Int* types, since the signedness never 
shows up explicitly in binary, oct, or hex representations. There's also 
the issues you've mentioned about whether hex is upper case or lower 
case, whether there's a leading sigil like 0 or 0o for oct, or 0x, \x, 
U+,... for hex. And so on. So you'll need to figure out what all the 
formats are you want to offer, but it should be straightforward to come 
up with an ADT like the one above, and then you can just case match on 
it to choose the specific format.


As for the class, if you run into too much type ambiguity and want to 
avoid the need for type signatures, then you can add an unused argument 
of type @a@ as is common in other core libraries needing to be H98 
compliant.


--
Live well,
~wren

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Eric Rasmussen
I only recently started learning Haskell and have had a difficult time
convincing other Python hackers to come on board. I see two things that
might help:

1) A resource to make informed decisions about different libraries.
Something that includes specific criteria like how long a library has been
out, how often it's maintained, how many people use it, etc. Ideally you'd
be able to see a quick table comparison of features across libraries that
perform similar tasks (roughly translated to something like: this xml
library is well established, has great documentation, and works for most
parsing tasks, while this other one is much faster but not widely used
yet).

2) Languages like Python make it easy to write fast performing code in a few
lines that will read/write files, split strings, and build lists or
dictionaries/associative arrays. There are very clever ways of doing all
these things Haskell, but it can involve several qualified imports and time
researching ByteStrings/Lazy ByteStrings/ByteString.Char8. It would be nice
to have a single module that exports some common text operations via
ByteStrings without requiring a lot of upfront research time learning to
work with ByteStrings, and possibly a limited export of Data.Map features as
well.

The second one would hold little interest for advanced developers of course,
but when someone is faced with a difficult learning task, if you give them a
strong starting point that produces results it can help motivate them to
keep learning. Is anyone working on either of these things or interested in
working on them? I'm not quite ready to produce high quality Haskell code
yet, but I'd like to contribute if I can.


On Thu, May 19, 2011 at 3:42 PM, David Leimbach leim...@gmail.com wrote:

 See the Haskell Platform.

 Sent from my iPhone

 On May 19, 2011, at 1:56 PM, Andrew Coppin andrewcop...@btinternet.com
 wrote:

  On 19/05/2011 09:34 PM, vagif.ve...@gmail.com wrote:
  Andrew, you are being non constructive.
 
  It seems I'm being misunderstood.
 
  Some people seem to hold the opinion that more libraries = better. I'm
 trying to voice the opinion that there is such a thing as too many
 libraries. The article I linked to explains part of why this is the case, in
 a better way than I've been able to phrase it myself.
 
  I'm not trying to say OMG, the way it is now completely sucks! I'm not
 trying to say you must do X right now! I'm just trying to put forward an
 opinion. The opinion that having too many libraries can be a problem, which
 some people don't seem to agree with. (Obviously it isn't *always* bad, I'm
 just saying that sometimes it can be.)
 
  That's all I was trying to say.
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe

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

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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-19 Thread John Lask

On 19/05/2011 10:31 PM, Heinrich Apfelmus wrote:

my comments for what their worth:

(1) wx and ghci: I successfully run wx in ghci (albeit) on windows. I 
take an alternative path to that proscribed by the current build process 
- I think principally so that I am able to run it in ghci, although I 
can not now recall the exact reason why I took the different route.


The current build process links the haskell wxcore library against the 
wxwdigets libraries directly. Once upon a time, the wxlibraries were 
wrapped as a C (dll) library, and the haskell libraries linked against 
this. I choose this route, and have no problems loading wxwdigets 
applications in ghci (on windows) ... and using OpenGL with them.


(2) on the question of GUI libraries in general.

I remind readers that the discussion of a GUI for haskell is no new 
thing, (cf. GUI API Taskforce)


http://www.haskell.org/pipermail/haskell/2001-September/007960.html
http://comments.gmane.org/gmane.comp.lang.haskell.gui/7
... and many more ...

a lot of which has been said recently, has been said before (it does
not make it less relevant, though) ...

there are two very different responses, the tactical and the strategic, 
they generally have very different time frames and cost (effort) required.


A tactical response might be to ensure that one of the (many) currently 
existing libraries (wxHaskell, qtHaskell, hs-fltk...) built and operated 
problem free on all platforms.


Whereas, a strategic response might be to have a cross platform gui 
library binding to low level platform libraries (Win32, X11, Cocoa)


Of course there are all sorts of variants in between.

A general problem with strategic response is they underestimate the 
effort required due to the long range horizon and the uncertainties 
involved.


if the question is what will provide me with the tools that I need today 
or tomorrow, which is the more efficacious response?




Conal Elliott wrote:

Last I heard, wx still had the problem of crashing its host the second
time
one opens a window (which is typical in ghci). And last I heard, Jeremy
O'Donoghue (cc'd) was exploring solutions but had very little time to
pursue
them. - Conal


Last I remember, the latest problem is that ghci is unable to link
libstdc++. But the crash problem is probably still there.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


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





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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-19 Thread KC
Do GUIs or interactive graphics in Haskell work a lot better on
Windows and/or various Linux distro's?


On Tue, May 17, 2011 at 4:24 PM, Conal Elliott co...@conal.net wrote:
 I still haven't found any way to do GUIs or interactive graphics in Haskell
 on a Mac that isn't plagued one or more of the following serious problems:

 * Incompatible with ghci, e.g., fails to make a window frame or kills the
 process the second time one opens a top-level window,
 * Goes through the X server, and so doesn't look or act like a Mac app,
 * Doesn't support OpenGL.

 A year or two ago, I put my Haskell GUI  graphics work on hold while
 waiting  hoping for a functioning pathway to open. So far I haven't heard
 of one.

 If anyone has found a solution, I'd love to hear!

   - Conal

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





-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-19 Thread Felipe Almeida Lessa
On Thu, May 19, 2011 at 9:23 PM, John Lask jvl...@hotmail.com wrote:
 A general problem with strategic response is they underestimate the effort
 required due to the long range horizon and the uncertainties involved.

The efforts in building a cross-platform GUI are not to be
underestimated.  Otherwise nobody would have problems in using
Gtk/Qt/Wx, all three well-developed by many hands.

IMHO, if you want programs with native look  feel on many platforms,
separate internal code from the GUI code and make one GUI for Windows,
another GUI using Gtk, another one using Qt and another one using
Cocoa (example [1]).  Even if your toolkit was perfect, platforms have
different practices and cultures that should be accounted for.

Cheers =),

[1] http://www.transmissionbt.com/

-- 
Felipe.

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


Re: [Haskell-cafe] Reverse Show instance

2011-05-19 Thread Ryan Ingram
Think of it this way:

-- Here is some data representing the typeclass 'Show'
data ShowDict a = ShowD (a - String)
show :: ShowDict a - a - String
show (ShowD f) a = f a

-- Here's a sample implementation for Strings
showString :: ShowDict String
showString = ShowD (\s - \ ++ escape s ++ \) where
   escape = concatMap escapeChar
   escapeChar '\\' = 
   escapeChar '' = \\\
   escapeChar c = [c]

-- Here's an implementation for pairs that uses the implementation for each
piece of the pair
showPair :: ShowDict a - ShowDict b - ShowDict (a,b)
showPair (ShowD sa) (ShowD sb) = ShowD (\(a,b) - ( ++ sa a ++ ,  ++ sb
b ++ ))

-- Here is what you are asking for
implementMe :: ShowDict (a,b) - ShowDict a
implementMe  = 


On Thu, May 19, 2011 at 2:08 PM, Andrew Coppin
andrewcop...@btinternet.comwrote:

  Cannot deduce (Show x) from context (Show (x, y)).
  Cannot deduce (Show y) from context (Show (x, y)).

 Um... seriously?

 From Prelude, we have

  Show x, Show y = Show (x, y)

 So clearly it works in the forward direction. But apparently not in the
 reverse direction.

 Is this a bug or a feature? (I.e., is there some obscure possibility I
 haven't thought of which means that doing the reverse inference would be
 incorrect?)

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

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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-19 Thread Evan Laforge
On Thu, May 19, 2011 at 5:32 PM, Felipe Almeida Lessa
felipe.le...@gmail.com wrote:
 On Thu, May 19, 2011 at 9:23 PM, John Lask jvl...@hotmail.com wrote:
 A general problem with strategic response is they underestimate the effort
 required due to the long range horizon and the uncertainties involved.

 The efforts in building a cross-platform GUI are not to be
 underestimated.  Otherwise nobody would have problems in using
 Gtk/Qt/Wx, all three well-developed by many hands.

Maybe I'm underestimating, but from working with fltk it doesn't seem
that bad.  It seems very daurting if you look at giant toolkits like
gtk, but the entire cocoa backend for fltk is just 3,500 lines of
objective C++.  The entire library is about 100k lines (via wc)
including headers, comments, doxygen, blank lines, etc. and I only use
a fraction of that.  Do it in the worlds best imperative language,
implement only the widgets I need, and do it in a more high level and
modern style, and omit stuff I don't like like DnD :), and it doesn't
seem very scary to me.  It's not going to have native look and feel
since the OS level just provides drawing primitives (otherwise I think
it would be a really complicated interface with lots of OS level
differences), but it provides access to the underlying window pointer
so you can add a native file chooser (as fltk does), etc.

I think the main thing would be not trying to support all GUI
features, just simple ones.

If I had a lot of GUI enthusiasm and no other project I would be
tempted to just try it.

 IMHO, if you want programs with native look  feel on many platforms,
 separate internal code from the GUI code and make one GUI for Windows,
 another GUI using Gtk, another one using Qt and another one using
 Cocoa (example [1]).  Even if your toolkit was perfect, platforms have
 different practices and cultures that should be accounted for.

I like this approach too.  I write the GUI in c++ and then export a
medium level C API of only 10-20 functions and FFI it.  I use fltk,
but if I really cared about the GUI then I could write native backends
for each platform.  If you really want to put a lot of effort into the
GUI and have it just right, I think it's the only option.

However, we could still have a library that provided a standard for
things like event types and event loop utilities.

And I think for GUIs that don't have to be native and have fancy
features, there is still a place for a simple cross platform GUI
library.

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Evan Laforge
 2) Languages like Python make it easy to write fast performing code in a few
 lines that will read/write files, split strings, and build lists or
 dictionaries/associative arrays. There are very clever ways of doing all
 these things Haskell, but it can involve several qualified imports and time
 researching ByteStrings/Lazy ByteStrings/ByteString.Char8. It would be nice
 to have a single module that exports some common text operations via
 ByteStrings without requiring a lot of upfront research time learning to
 work with ByteStrings, and possibly a limited export of Data.Map features as
 well.

It's basically just Data.Text, Data.ByteString, Data.Map, and various
things from the prelude.  The problem is that once people learn where
those things are they forget their own learning process and start
thinking its obvious and everyone should know.

Maybe a python - haskell equivalents cheatsheet could serve the
purpose?  And you're probably a good person to do it since you haven't
forgotten the learning process yet :)  You can just register on the
wiki and start adding things.  Maybe the page even already exists.

E.g.:

s = open(fn).read() == s - Text.readFile fn

'\n'.join(sorted(s.split('\n'))) == Text.unlines . List.sort . Text.lines

lineByWord = dict(tuple(line.split(':', 1)) for line in lines) ==
  lineByWord = Map.fromList [(word, rest) | line - lines, let (word,
rest) = Text.break (==':') line]

now = datetime.datetime.now()
print '\n'.join((now - datetime.strptime(..., m)).days for m in
re.groups(r'...', line))
  == you tell me :)

Or whatever other things you are doing in python that you wish you
could do as easily in haskell.

If they're used to the above style of python, then there are pretty
direct translations for everything.  If they are used to a more
imperative style then I think some upfront research time is
unavoidable, but it'll be good for them.

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