[Haskell-cafe] ghci can't load file whose name contains non-ASCII chars?

2012-03-28 Thread Johannes Waldmann
I must be making some obvious mistake here,
but I'm not seeing it. The file name contains O-umlaut,
and the OS handles it fine, but ghci does not like it
(although it accepts umlauts in the contents of the file
(UTF-8) e.g., as a module name)

$ cat fÖÖbar.hs 
main = print $ product [1..100]

$ ghci fÖÖbar.hs 
GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.

no location info: can't find file: f??bar.hs
Failed, modules loaded: none.


this is on a standard ubuntu install (11.10 and 11.04) with 

$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=en_US.UTF-8
...

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.1
$ uname -a
Linux octopus 3.0.0-16-generic #29-Ubuntu SMP Tue Feb 14 12:48:51 UTC 2012
x86_64 x86_64 x86_64 GNU/Linux



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


Re: [Haskell-cafe] ghci can't load file whose name contains non-ASCII chars?

2012-03-28 Thread Ivan Lazar Miljenovic
On 28 March 2012 18:44, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote:
 I must be making some obvious mistake here,
 but I'm not seeing it. The file name contains O-umlaut,
 and the OS handles it fine, but ghci does not like it
 (although it accepts umlauts in the contents of the file
 (UTF-8) e.g., as a module name)

 $ cat fÖÖbar.hs
 main = print $ product [1..100]

 $ ghci fÖÖbar.hs
 GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.

 no location info: can't find file: f??bar.hs
 Failed, modules loaded: none.


 this is on a standard ubuntu install (11.10 and 11.04) with

 $ locale
 LANG=en_US.UTF-8
 LANGUAGE=
 LC_CTYPE=en_US.UTF-8
 ...

 $ ghc --version
 The Glorious Glasgow Haskell Compilation System, version 7.4.1
 $ uname -a
 Linux octopus 3.0.0-16-generic #29-Ubuntu SMP Tue Feb 14 12:48:51 UTC 2012
 x86_64 x86_64 x86_64 GNU/Linux


I'm able to duplicate this (also on a 64bit Linux install with 7.4.1).



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



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

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


Re: [Haskell-cafe] Regarding Haskell FFI

2012-03-28 Thread Simon Marlow

On 27/03/2012 08:56, rajendra prasad wrote:

Hi,

I am trying to load the DLL(Wrapper.dll) in my code(Main.hs). When I am
placing the dll in local directory, I am able to load it through
following command:

ghci Main.hs -L. -lWrapper


But, I am not able to load it if I am putting it in some other
directory(../../bin). I used the following command:

ghci Main.hs -L../../bin/ -lWrapper

I doubt I am not using the correct way to specify the path of dll in the
command.

Please correct me if I am wrong.


What version of GHC is this?  We fixed some bugs in that area recently.

Cheers,
Simon



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


Re: [Haskell-cafe] Regarding Haskell FFI

2012-03-28 Thread rajendra prasad
Hi,

I am using GHC version 7.0.4.

Thanks,
Rajendra




On Wed, Mar 28, 2012 at 2:09 PM, Simon Marlow marlo...@gmail.com wrote:

 On 27/03/2012 08:56, rajendra prasad wrote:

 Hi,

 I am trying to load the DLL(Wrapper.dll) in my code(Main.hs). When I am
 placing the dll in local directory, I am able to load it through
 following command:

 ghci Main.hs -L. -lWrapper


 But, I am not able to load it if I am putting it in some other
 directory(../../bin). I used the following command:

 ghci Main.hs -L../../bin/ -lWrapper

 I doubt I am not using the correct way to specify the path of dll in the
 command.

 Please correct me if I am wrong.


 What version of GHC is this?  We fixed some bugs in that area recently.

 Cheers,
Simon



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


Re: [Haskell-cafe] Regarding Haskell FFI

2012-03-28 Thread Simon Marlow

I think the fix eventually made its way into 7.4.1.  This is the patch:

http://hackage.haskell.org/trac/ghc/changeset/d146fdbbf8941a8344f0ec300e79dbeabc08d1ea

Cheers,
Simon


On 28/03/2012 09:57, rajendra prasad wrote:

Hi,

I am using GHC version 7.0.4.

Thanks,
Rajendra




On Wed, Mar 28, 2012 at 2:09 PM, Simon Marlow marlo...@gmail.com
mailto:marlo...@gmail.com wrote:

On 27/03/2012 08:56, rajendra prasad wrote:

Hi,

I am trying to load the DLL(Wrapper.dll) in my code(Main.hs).
When I am
placing the dll in local directory, I am able to load it through
following command:

ghci Main.hs -L. -lWrapper


But, I am not able to load it if I am putting it in some other
directory(../../bin). I used the following command:

ghci Main.hs -L../../bin/ -lWrapper

I doubt I am not using the correct way to specify the path of
dll in the
command.

Please correct me if I am wrong.


What version of GHC is this?  We fixed some bugs in that area recently.

Cheers,
Simon






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


Re: [Haskell-cafe] Fail-back monad

2012-03-28 Thread Alberto G. Corona
Sorry, the text example again without HTML formatting:


test= runBackT $ do
   lift $ print will not return back here
liftBackPoint $ print will return here
n2  - lift $ getLine
lift $ print second input
n3  - lift $  getLine
if n3 == back
   then  fail 
   else lift $ print  $ n2++n3


I wrote a blog entry about this :

 http://haskell-web.blogspot.com.es/2012/03/failback-monad.html


2012/3/28 Alberto G. Corona agocor...@gmail.com:
 Hi Haskellers.

 In my package MFlow [1] I program an entire web  navigation in a
 single procedure. That happened  in the good-old WASH web application
 framework.
 The problem is the back button in the Browser.
 To go back in the code to the previous interactions when the data
 input does not match the expected because the user pressed the back
 button one or more times, i came across this Monad specimen,: that
 solves the problem.


 data FailBack a = BackPoint a   -- will go back to this point
                             | NoBack a       . -- Normal outcome
                             | GoBack            -- exception:: must
 go to the last backPoint

 newtype BackT m a = BackT { runBackT :: m (FailBack a ) }

 -- this monad nas a loop

 instance Monad m = Monad (BackT  m) where
    fail   _ = BackT $ return GoBack
    return x = BackT . return $ NoBack x
    x = f  = BackT $ loop
     where
     loop = do
        v - runBackT x
        case v of
            NoBack y  - runBackT (f y)  -- business as usual
            BackPoint y  - do
                 z - runBackT (f y)
                 case z of
                  GoBack  - loop          -- if x was a backpoint,
 then redirects the flow to this backpoint
                  other - return other
            GoBack - return  GoBack --propagate the signal back


  This monad does not perform exploration of alternatives as is the
 case of MonadPlus instances. It does not perform the kind of
 backtracking of nondeterministic  three navigations in the Prolog
 style. It just go back to the last point where the computation can
 restart again in a  sequence of actions.

 In this example:


 liftBackPoint f= BackT $ f = \x - return $ BackPoint x

 test= runBackT $ do
       lift $ print will not return back here
        liftBackPoint $ print will return here
        n2  lt;- lift $ getLine
        lift $ print second input
        n3  lt;- lift $  getLine
        if n3 == back
                   then  fail 
                   else lift $ print  $ n2++n3

 Whenever the second input is back The procedure will go back to
 where liftBackPoint is. Otherwise, it will return the concatenation of
 the two inputs. If the underlying monad is an instance of MonadState,
 it can transport the state that caused the failure to the backpoint.

 Are there something similar? May it be functionally equivalent to
 something simpler or with more grounds?
  I looked at some exception monads out there, but they did not seems
 to share the same idea

 [1] 
 http://haskell-web.blogspot.com.es/2012/02/web-application-server-with-stateful.html

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


Re: [Haskell-cafe] Regarding Haskell FFI

2012-03-28 Thread rajendra prasad
Thank you very much for the quick reply.

Regards,
Rajendra

On Wed, Mar 28, 2012 at 2:35 PM, Simon Marlow marlo...@gmail.com wrote:

 I think the fix eventually made its way into 7.4.1.  This is the patch:

 http://hackage.haskell.org/**trac/ghc/changeset/**
 d146fdbbf8941a8344f0ec300e79db**eabc08d1eahttp://hackage.haskell.org/trac/ghc/changeset/d146fdbbf8941a8344f0ec300e79dbeabc08d1ea

 Cheers,
Simon



 On 28/03/2012 09:57, rajendra prasad wrote:

 Hi,

 I am using GHC version 7.0.4.

 Thanks,
 Rajendra




 On Wed, Mar 28, 2012 at 2:09 PM, Simon Marlow marlo...@gmail.com
 mailto:marlo...@gmail.com wrote:

On 27/03/2012 08:56, rajendra prasad wrote:

Hi,

I am trying to load the DLL(Wrapper.dll) in my code(Main.hs).
When I am
placing the dll in local directory, I am able to load it through
following command:

ghci Main.hs -L. -lWrapper


But, I am not able to load it if I am putting it in some other
directory(../../bin). I used the following command:

ghci Main.hs -L../../bin/ -lWrapper

I doubt I am not using the correct way to specify the path of
dll in the
command.

Please correct me if I am wrong.


What version of GHC is this?  We fixed some bugs in that area recently.

Cheers,
Simon





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


[Haskell-cafe] GSoC project idea: haskell-type-exts

2012-03-28 Thread Niklas Broberg
See ticket here: http://hackage.haskell.org/trac/summer-of-code/ticket/1620

== What? ==

The haskell-src-exts library (HSE) is very popular for manipulating Haskell
source code in a wide range of scenarios, such as (syntactic) preprocessors
(e.g. hsx), syntax highlighting, refactoring and code inspection (e.g.
hlint), etc.

A commonly sought feature, that would enable a multitude of new and
improved scenarios, is the ability to type-check the code, and annotate the
AST with type information. Type-driven refactoring, type-aware code
inspection, type-based preprocessing, ... Lots of pure awesomeness lies in
that direction.

Sadly, HSE has no type-checking abilities. For those who seek such, we are
forced to point in the direction of the dark cave that is the GHC API.
While GHC is an utterly awesome compiler, there are several reasons why
this is not an ideal situation. First, GHC was designed and built for
optimization, which means that even the early stages of the compilation
pipeline contain features that cater to later optimization, but that are
(at best) unnecessary for a front-end tool. Second, the API into GHC
internals is defined as an afterthought. Some good work has been done to
make it somewhat palatable, but it remains a fact that GHC's primary
purpose is not to be a library for integration in tools, and this shows.
Overall, depending on GHC when all you want is front-end capabilities like
parsing and typechecking, is really like using the proverbial sledge
hammer.

Also, at the meta level, GHC deserves competition. Right now GHC is de
facto the only implementation of Haskell, and as such it more or less
defines the progress of Haskell. Too often this leads to overly pragmatic
choices, which lead to inconsistencies and headaches for tool programmers.
Having a separate, stand-alone front end library would help set higher
standards.

So - what we need is a type checker that works on the HSE AST:
haskell-type-exts!


== How? ==

I now hear you think: This is too much, an enormous project, surely it
can't be done as a GSoC project? Sure it can! By walking in the footsteps
of giants, and following GHC's approach. This can be achieved by closely
observing the documentation provided by [1] and [2], with a bit of [3]
thrown into the mix.

I already have a basic library that provides most of the core framework
necessary to cover extensions, but at this time it's mostly just
scaffolding. It needs a lot of love, to provide cover for all the various
available extensions, but I'm confident it can be done satisfactorily as a
GSoC project.

Still, it would be reasonable to modularize the task. Certain features are
more crucial than others to support, simply because they have a more
profound impact on the overall type-checking. Higher-rank types, GADTs and
type families (and fundeps) are likely the most important ones to get
right.

There are also some design issues to get right (e.g. using pure
substitution vs efficient mutable variables).

I (Niklas Broberg) am more than willing to mentor this project.


== Further reading: ==
[1] S. Peyton Jones, D. Vytiniotis, S. Weirich, and M. Shields. Practical
type inference for arbitrary-rank types.
[2] D. Vytiniotis, S. Peyton Jones, T. Schrijvers, M. Sulzmann.
OutsideIn(X) – Modular type inference with local assumptions
[3] M. P. Jones. Typing Haskell in Haskell
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Mathematics and Statistics libraries

2012-03-28 Thread Aleksey Khudyakov
 There is the plot[1] library which provides for updateable plots from GHCi
 REPL and has a gnuplot-like interface.  I wrote it for this very reason, a
 mathematics/statistics development environment.

 It uses Data.Vector.Storable, which provides for compatability with both
 statistics and hmatrix packages (as well as hstatistics).

Looks very interesting. I'll try it out.


 I think talking about data frames is a bit pointless unless we specify
 what is data frame. Basically there are two representations of tabular
 data structure: array of tuples or tuple of arrays. If you want first go
 for Data.Vector.Vector YourData. If you want second you'll probably end
 up with some HList-like data structure to hold arrays.

 Matrices from hmatrix are easily converted to rows or columns of
 Data.Vector.Storable and can be sliced and otherwise manipulated.

That's why I said that homogenous data frame is simple. But if you want to
have columns which hold values with different type they lo longer a matrix
and thing become way more interesting.

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


Re: [Haskell-cafe] ghci can't load file whose name contains non-ASCII chars?

2012-03-28 Thread Aleksey Khudyakov
On Wed, Mar 28, 2012 at 11:49 AM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 On 28 March 2012 18:44, Johannes Waldmann waldm...@imn.htwk-leipzig.de 
 wrote:
 I must be making some obvious mistake here,
 but I'm not seeing it. The file name contains O-umlaut,
 and the OS handles it fine, but ghci does not like it
 (although it accepts umlauts in the contents of the file
 (UTF-8) e.g., as a module name)

I looks like GHC correctly decodes command line parameters and then
truncates them to 8-bit.

$ ghci ффф
command line:
Could not find module `DDD'

 fromEnum 'ф' `mod` 256 == fromEnum 'D'
True

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


Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-28 Thread Florian Hartwig
Hi again,
I just submitted my proposal on the GSoC website. You can find it here:
http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/florianhartwig/1
I would be very grateful if someone could read over it and tell me if
it makes sense and if/how it could be improved.
Cheers,
Florian

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


[Haskell-cafe] ANNOUNCE: haskell-src-exts-1.13.0

2012-03-28 Thread Niklas Broberg
Fellow Haskelleers,

I'm pleased to announce the release of haskell-src-exts-1.13.0!

* On hackage: http://hackage.haskell.org/package/haskell-src-exts
* Via cabal: cabal install haskell-src-exts
* Darcs repo: http://code.haskell.org/haskell-src-exts

It's been a *very short* while since the last update before this, and
another (smallish) major release it is. Sorry about that (especially to
Neil who was quick to update).

The main update of this release is to add support for DoAndIfThenElse,
which means haskell-src-exts at long last is compliant with Haskell2010.
This is also the cause for the backwards-incompatible change: default parse
mode is now to use Haskell2010 mode. In particular this means that
NPlusKPatterns is no longer recognized by default. No old code using
haskell-src-exts should fail to compile (unless really unlucky with
clashing imports from L.H.E.Extension), but it may now fail to work on some
Haskell98-compliant source files.

Changelog:

1.12.0 -- 1.13.0
===

* Add extensions DoAndIfThenElse and NPlusKPatterns to
Language.Haskell.Exts.Extensions.

* DoAndIfThenElse is now supported, at long last,
making HSE compatible with Haskell2010

* Introduce haskell98 and haskell2010 extension groups,
exported from Language.Haskell.Exts.Extensions.

* Backwards-incompatible change: default parse mode
is now to use haskell2010, which means the following
features are recognized by default: DoAndIfThenElse,
PatternGuards, ForeignFunctionInterface, EmptyDataDecls.
NPlusKPatterns is no longer recognized by default.


Cheers,

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


Re: [Haskell-cafe] Fail-back monad

2012-03-28 Thread Stephen Tetley
Maybe this is a version of William Harrison's DebugT monad with
rollback, listed in his periodic table of effects?

http://www.cs.missouri.edu/~harrisonwl/Presentations/UIUCFM05.ppt

I've never seen a definition of the monad itself...
http://www.haskell.org/pipermail/beginners/2010-January/003371.html

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


Re: [Haskell-cafe] Fail-back monad

2012-03-28 Thread Alberto G. Corona
Hi Stephen:

It could be:

It performs a rollback indeed.
 I guess that this monad can be used in something similar to
nonblocking (multilevel)  transactions.

if GoBack is changed to Goback String, and  a trace string is
added to each NoBack step, then each NoBack step could sum the traces
of all the  previous steps. The when GoBack condition is reached, it
can transport back the entire trace of the failed execution. to the
BackPoint


2012/3/28 Stephen Tetley stephen.tet...@gmail.com:
 Maybe this is a version of William Harrison's DebugT monad with
 rollback, listed in his periodic table of effects?

 http://www.cs.missouri.edu/~harrisonwl/Presentations/UIUCFM05.ppt

 I've never seen a definition of the monad itself...
 http://www.haskell.org/pipermail/beginners/2010-January/003371.html

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


[Haskell-cafe] for = flip map

2012-03-28 Thread Johannes Waldmann
Good: we have  mapM, and we have forM ( = flip mapM )  .

Sure this is just a convenience, and indeed
forM xs $ \ x - do ... is quite handy,
especially if xs is really small, 
and ... is some larger expression.

Bad: we have  map,  but we are missing:  for ( = flip map ) .

The function is very convenient, for the same reasons as above.
I can't remember how often I typed for = flip map in a source file.
I never put this definition in a module either, 
since the import statement would be longer than the definition.

So, I'm all for for .  

In Data.List? In the Prelude? (Should put it right next to map.) 

- J.W.


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


Re: [Haskell-cafe] for = flip map

2012-03-28 Thread Christopher Done
Similar proposal here:
http://www.reddit.com/r/haskell/comments/qy990/suggestion_for_flip_map/

It seems generally favorable. Might as well generalize it though and have
flip fmap.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] for = flip map

2012-03-28 Thread Matthew Steele
Doesn't for already exist, in Data.Traversable?   Except that for =
flip traverse.

http://www.haskell.org/hoogle/?hoogle=for

Cheers,
-Matthew

On Wed, Mar 28, 2012 at 3:58 PM, Johannes Waldmann
waldm...@imn.htwk-leipzig.de wrote:
 Good: we have  mapM, and we have forM ( = flip mapM )  .

 Sure this is just a convenience, and indeed
 forM xs $ \ x - do ... is quite handy,
 especially if xs is really small,
 and ... is some larger expression.

 Bad: we have  map,  but we are missing:  for ( = flip map ) .

 The function is very convenient, for the same reasons as above.
 I can't remember how often I typed for = flip map in a source file.
 I never put this definition in a module either,
 since the import statement would be longer than the definition.

 So, I'm all for for .

 In Data.List? In the Prelude? (Should put it right next to map.)

 - J.W.


 ___
 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] for = flip map

2012-03-28 Thread Christopher Done
On 28 March 2012 22:05, Matthew Steele mdste...@alum.mit.edu wrote:
 Doesn't for already exist, in Data.Traversable?   Except that for =
 flip traverse.

Traverse doesn't fit the type of fmap, it demands an extra type constructor:

traverse :: (Traversable t,Applicative f) = (a - f b) - t a - f (t b)

fmap :: Functor f = (a - b) - f a - f b

Note the (a - f b) instead of (a - b).

E.g.

fmap :: (a - b) - [a] - [b]

can't be expressed with traverse, you can only get this far:

traverse :: (a - [b]) - [a] - [[b]]

Unless I'm missing something.

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


[Haskell-cafe] winhugs interrupts

2012-03-28 Thread Doug McIlroy
On windows I have long used hugs under cygwin, but hugs
doesn't get along well with cygwin's latest terminal
emulator.  So I switched to winhugs.  Small problem
that looms big: how do you interrupt an interminable
expression evaluation in winhugs?

Doug

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


Re: [Haskell-cafe] [Haskell] ANNOUNCE: haskell-src-exts-1.13.0

2012-03-28 Thread dag.odenh...@gmail.com
On 28 March 2012 21:05, Jurriaan Hage j.h...@uu.nl wrote:


 Our first year students will be very unhappy to hear this.


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


Re: [Haskell-cafe] [Haskell] ANNOUNCE: haskell-src-exts-1.13.0

2012-03-28 Thread Felipe Almeida Lessa
On Wed, Mar 28, 2012 at 5:52 PM, dag.odenh...@gmail.com
dag.odenh...@gmail.com wrote:
 Wait, what?

Perhaps they were assigned the task of updating haskell-src-exts code
to support Haskell2010? =)

-- 
Felipe.

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


[Haskell-cafe] Can't install snap (problem with syb)

2012-03-28 Thread Michael Iles

I uninstalled ghc, removed my ~/.cabal directory, reinstalled ghc, then
tried to install snap. I get:

$ cabal install snap
Resolving dependencies...
Downloading syb-0.3.6...
command line: cannot satisfy -package Cabal-1.14.0:
Cabal-1.14.0-0338b6f52e6e6a56054371a110e1d79e is unusable due to
missing or recursive dependencies:
  directory-1.1.0.2-8957520ced1fb19160c3a6126dcccfaa
process-1.1.0.1-91185c964ab744c1f3cbca1863d2ba45
(use -v for more information)
cabal: Error: some packages failed to install:
aeson-0.6.0.0 depends on syb-0.3.6 which failed to install.
snap-0.8.0.2 depends on syb-0.3.6 which failed to install.
syb-0.3.6 failed during the configure step. The exception was:
ExitFailure 1



Any ideas?

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


Re: [Haskell-cafe] for = flip map

2012-03-28 Thread Yves Parès
Think of traverse as a mapA, as it's just like Data.Traversable.mapM,
but with the Applicative class constraint instead of the Monad one.
I've always wondered why it isn't called this way, sequenceM equivalent for
Applicatives is sequenceA for instance.

Le 28 mars 2012 22:19, Christopher Done chrisd...@googlemail.com a écrit :

 On 28 March 2012 22:05, Matthew Steele mdste...@alum.mit.edu wrote:
  Doesn't for already exist, in Data.Traversable?   Except that for =
  flip traverse.

 Traverse doesn't fit the type of fmap, it demands an extra type
 constructor:

 traverse :: (Traversable t,Applicative f) = (a - f b) - t a - f (t b)

 fmap :: Functor f = (a - b) - f a - f b

 Note the (a - f b) instead of (a - b).

 E.g.

 fmap :: (a - b) - [a] - [b]

 can't be expressed with traverse, you can only get this far:

 traverse :: (a - [b]) - [a] - [[b]]

 Unless I'm missing something.

 ___
 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] Can't install snap (problem with syb)

2012-03-28 Thread Yves Parès
It may come from the version of GHC you're using (Cabal version is fixed
for one specific GHC version).
Which one is it?

Le 28 mars 2012 23:05, Michael Iles michael.i...@ca.ibm.com a écrit :

 I uninstalled ghc, removed my ~/.cabal directory, reinstalled ghc, then
 tried to install snap. I get:

 $ cabal install snap
 Resolving dependencies...
 Downloading syb-0.3.6...
 command line: cannot satisfy -package Cabal-1.14.0:
  Cabal-1.14.0-0338b6f52e6e6a56054371a110e1d79e is unusable due to missing
 or recursive dependencies:
  directory-1.1.0.2-8957520ced1fb19160c3a6126dcccfaa
 process-1.1.0.1-91185c964ab744c1f3cbca1863d2ba45
  (use -v for more information)
 cabal: Error: some packages failed to install:
 aeson-0.6.0.0 depends on syb-0.3.6 which failed to install.
 snap-0.8.0.2 depends on syb-0.3.6 which failed to install.
 syb-0.3.6 failed during the configure step. The exception was:
 ExitFailure 1



 Any ideas?

 Mike.


 ___
 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] Can't install snap (problem with syb)

2012-03-28 Thread Michael Iles

I'm using ghc 7.4.1 (from the Ubuntu Precise repository).

Don't know if this is relevant but ghc-pkg list tells me that I have:

/var/lib/ghc/package.conf.d
   Cabal-1.14.0
   directory-1.1.0.2
   process-1.1.0.1
   ...


Mike.





From:   Yves Parès yves.pa...@gmail.com
To: Michael Iles/Ottawa/IBM@IBMCA
Cc: haskell-cafe@haskell.org
Date:   03/28/2012 05:13 PM
Subject:Re: [Haskell-cafe] Can't install snap (problem with syb)
Sent by:limestr...@gmail.com



It may come from the version of GHC you're using (Cabal version is fixed
for one specific GHC version).
Which one is it?

Le 28 mars 2012 23:05, Michael Iles michael.i...@ca.ibm.com a écrit :
  I uninstalled ghc, removed my ~/.cabal directory, reinstalled ghc, then
  tried to install snap. I get:

  $ cabal install snap
  Resolving dependencies...
  Downloading syb-0.3.6...
  command line: cannot satisfy -package Cabal-1.14.0:
  Cabal-1.14.0-0338b6f52e6e6a56054371a110e1d79e is unusable due to missing
  or recursive dependencies:
  directory-1.1.0.2-8957520ced1fb19160c3a6126dcccfaa
  process-1.1.0.1-91185c964ab744c1f3cbca1863d2ba45
  (use -v for more information)
  cabal: Error: some packages failed to install:
  aeson-0.6.0.0 depends on syb-0.3.6 which failed to install.
  snap-0.8.0.2 depends on syb-0.3.6 which failed to install.
  syb-0.3.6 failed during the configure step. The exception was:
  ExitFailure 1



  Any ideas?

  Mike.


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

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


Re: [Haskell-cafe] for = flip map

2012-03-28 Thread ezra
I would very much like to see a standard function for flip map along
these lines. I think it would make a lot of code more readable.

Like the OP, I use for in my own code. It's unfortunate that
Data.Traversable takes the name with another type. Two options would be
to (a) reuse the name in Data.List and force people to qualify as
necessary, or (b) choose another name for flip map.

Regarding other possible names: forall is a keyword and forAll is used
by QuickCheck. One possibility would be foreach.

Ezra

On Wed, Mar 28, 2012, at 10:19 PM, Christopher Done wrote:
 On 28 March 2012 22:05, Matthew Steele mdste...@alum.mit.edu wrote:
  Doesn't for already exist, in Data.Traversable?   Except that for =
  flip traverse.
 
 Traverse doesn't fit the type of fmap, it demands an extra type
 constructor:
 
 traverse :: (Traversable t,Applicative f) = (a - f b) - t a - f (t b)
 
 fmap :: Functor f = (a - b) - f a - f b
 
 Note the (a - f b) instead of (a - b).
 
 E.g.
 
 fmap :: (a - b) - [a] - [b]
 
 can't be expressed with traverse, you can only get this far:
 
 traverse :: (a - [b]) - [a] - [[b]]
 
 Unless I'm missing something.
 
 ___
 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] Can't install snap (problem with syb)

2012-03-28 Thread Brandon Allbery
On Wed, Mar 28, 2012 at 17:05, Michael Iles michael.i...@ca.ibm.com wrote:

 I uninstalled ghc, removed my ~/.cabal directory, reinstalled ghc, then
 tried to install snap. I get:

Did you also remove ~/.ghc?  Libraries are actually installed and
registered there, not under ~/.cabal.  Although this shouldn't be a problem
if any Cabal-installed libraries were for a different version of ghc, it's
safest to remove both.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Can't install snap (problem with syb)

2012-03-28 Thread .
Did you install the haskell-platform package?
What is the output of ghc-pkg check?

On Wed, Mar 28, 2012 at 5:30 PM, Brandon Allbery allber...@gmail.comwrote:

 On Wed, Mar 28, 2012 at 17:05, Michael Iles michael.i...@ca.ibm.comwrote:

  I uninstalled ghc, removed my ~/.cabal directory, reinstalled ghc, then
 tried to install snap. I get:

 Did you also remove ~/.ghc?  Libraries are actually installed and
 registered there, not under ~/.cabal.  Although this shouldn't be a problem
 if any Cabal-installed libraries were for a different version of ghc, it's
 safest to remove both.

 --
 brandon s allbery  allber...@gmail.com
 wandering unix systems administrator (available) (412) 475-9364 vm/sms


 ___
 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] Can't install snap (problem with syb)

2012-03-28 Thread Michael Iles

Hey that fixed it!  (Removing ~/.ghc.)

Thanks!

Mike.





From:   Brandon Allbery allber...@gmail.com
To: Michael Iles/Ottawa/IBM@IBMCA
Cc: haskell-cafe@haskell.org
Date:   03/28/2012 06:32 PM
Subject:Re: [Haskell-cafe] Can't install snap (problem with syb)



On Wed, Mar 28, 2012 at 17:05, Michael Iles michael.i...@ca.ibm.com
wrote:
  I uninstalled ghc, removed my ~/.cabal directory, reinstalled ghc, then
  tried to install snap. I get:


Did you also remove ~/.ghc?  Libraries are actually installed and
registered there, not under ~/.cabal.  Although this shouldn't be a problem
if any Cabal-installed libraries were for a different version of ghc, it's
safest to remove both.

--
brandon s allbery                                      allber...@gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
inline: graycol.gif___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Can't install snap (problem with syb)

2012-03-28 Thread Albert Y. C. Lai

On 12-03-28 06:30 PM, Brandon Allbery wrote:

Did you also remove ~/.ghc?  Libraries are actually installed and
registered there, not under ~/.cabal.


Reality is less simplistic than that. .ghc has library metadata. .cabal 
has library files. See my

http://www.vex.net/~trebla/haskell/sicp.xhtml
and verify, verify, verify.

Since GHC simply trusts its metadata (and not re-scan library files to 
re-discover libraries), metadata dominates.


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


Re: [Haskell-cafe] for = flip map

2012-03-28 Thread Matthew Steele

On Mar 28, 2012, at 4:19 PM, Christopher Done wrote:


On 28 March 2012 22:05, Matthew Steele mdste...@alum.mit.edu wrote:

Doesn't for already exist, in Data.Traversable?   Except that for =
flip traverse.


Traverse doesn't fit the type of fmap, it demands an extra type  
constructor:


traverse :: (Traversable t,Applicative f) = (a - f b) - t a - f  
(t b)


fmap :: Functor f = (a - b) - f a - f b

Note the (a - f b) instead of (a - b).

E.g.

fmap :: (a - b) - [a] - [b]

can't be expressed with traverse, you can only get this far:

traverse :: (a - [b]) - [a] - [[b]]

Unless I'm missing something.


That right; I was simply pointing out that the name 'for' is already  
taken by an existing base function.


Things might be more consistant if 'traverse' and 'for' were instead  
called 'mapA' and 'forA' (by analogy with 'mapM' and 'forM').  Then  
one could add 'for = flip map' to base without conflict.  But for some  
reason, that's not the case.


Cheers,
-Matthew


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


Re: [Haskell-cafe] adding the elements of two lists

2012-03-28 Thread Doug McIlroy
 Date: Tue, 27 Mar 2012 11:03:54 +1300
 From: Richard O'Keefe o...@cs.otago.ac.nz
 Subject: Re: [Haskell-cafe] adding the elements of two lists
 To: jerzy.karczmarc...@unicaen.fr
 Cc: haskell-cafe@haskell.org
 
 And *that* is why I stopped trying to define instance Num t = Num [t].
 If I KNEW that the length of the lists is ... fixed ... then the type
 wasn't *really* [t], but some abstract type that happened to be implemented
 as [t], and that abstract type deserved a newtype name of its own.
 
 Naming the type
  - makes the author's intent clearer to readers
  - lets the compiler check it's used consistently
  - lets you have instances that don't match instances for
other abstract types that happen to have the same implementation
  - provides a natural place to document the purpose of the type
  - gives you a way to enforce the intended restrictions
 all for zero run-time overhead.

Quite taken by this manifesto for high style and morality,
I resolved to do right by some old code, of which I had
been quite proud: www.cs.dartmouth.edu/~doug/powser.html.
Sadly, the exercise took some bloom off the rose. What
the code gained in honesty and safety, it lost in beauty
and readability.

Here's the contrast, seen in overloading arithmetic to
handle addition and multiplication of power series.

- without newtype

toSeries f = f : repeat 0   -- coerce scalar to series

instance Num a = Num [a] where
   (f:fs) + (g:gs) = f+g : fs+gs
   (f:fs') * gs@(g:gs') = f*g : fs'*gs + (toSeries f)*gs'

- with newtype

newtype Num a = PS a = PS [a] deriving (Show, Eq)

fromPS (PS fs) = fs -- extract list
toPS f = PS (f : repeat 0)  -- coerce scalar to series

instance Num a = Num (PS a) where
   (PS (f:fs)) + (PS (g:gs)) = PS (f+g : fs+gs)
   (PS (f:fs)) * gPS@(PS (g:gs)) =
  PS $ f*g : fromPS ((PS fs)*gPS + (toPS f)*(PS gs))

The code suffers a pox of PS. When one goes on to
introduce efficiencies and generalize to handle
finite series (polynomials), it only gets worse.

One unpleasant technical problem: the deriving
clause is almost useless--one can't print or
detect equality of infinite objects.  For output  
one must apply something like (take 10 . fromPS).

Yet this modest package would likely pose
problems if it were combined with others in a
grander suite for automated mathematics.  What to
do? I think I might write the package without
newtype, and then wrap it in PS for export in hopes
of exploiting the advantages of both styles.

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


[Haskell-cafe] Haskell Weekly News: Issue 220

2012-03-28 Thread Daniel Santa Cruz
Welcome to issue 220 of the HWN, an issue covering crowd-sourced bits
of information about Haskell from around the web. This issue covers the
week of March 18 to 24, 2012.

Quotes of the Week

   * shachaf: Type classes are a scary story that you tell new
  Haskellers so they can go to sleep at night.

   * acowley: Parametric polymorphism is the inspiring story you tell
  them to get them riled up and raring to go.
  It's like Braveheart for programmers.

   * monochrom: the purpose of types is to ban more programs

   * rostayob: I was a type constructor, then I took an arrow in the
   kind

   * shachaf: @let otherfoolish = not otherwise

   * flebron: Monoidal objects in the monoidal category of endofunctors
  on a category. I took a small detour through tensor
  products to understand monoidal categories better, with
  one example of such a product.
 mauke: I have no idea what you just said

   * weexplat: starts a proposal to replace launchMissiles with
   atomicDestroyBiosphere

   * monochrom: rumour: SPJ will write a thick book A New Science of
Kind

   * JonathanShapiro: [on abandoning BitC] And I *still* don't believe
  in monads. :-)

Top Reddit Stories

   * Starting the Mezzo Haskell Book
 Domain: yesodweb.com, Score: 58, Comments: 28
 On Reddit: [1] http://goo.gl/pOSlR
 Original: [2] http://goo.gl/ecy4O

   * First patches for iPhone cross compiler against GHC head
 Domain: haskell.org, Score: 55, Comments: 27
 On Reddit: [3] http://goo.gl/OOAai
 Original: [4] http://goo.gl/p7C3L

   * Retrospective thoughts on BitC by its author, and why type classes
didn't work for him
 Domain: coyotos.org, Score: 44, Comments: 22
 On Reddit: [5] http://goo.gl/0sL80
 Original: [6] http://goo.gl/5pCp2

   * Google Summer of Code 2012 - Haskell.org is participating
 Domain: haskell.org, Score: 42, Comments: 11
 On Reddit: [7] http://goo.gl/9EwzD
 Original: [8] http://goo.gl/XqcUJ

   * Conduits vs. Pipes. Using Void as an Input or Output type can reduce
the number of concepts (source, sink, conduit) from 3 to 1 (pipe).
 Domain: twanvl.nl, Score: 34, Comments: 50
 On Reddit: [9] http://goo.gl/bc8RB
 Original: [10] http://goo.gl/eb7oz

   * Announcing conduit 0.3
 Domain: yesodweb.com, Score: 33, Comments: 9
 On Reddit: [11] http://goo.gl/JrgV0
 Original: [12] http://goo.gl/OsDl7

   * Haskell for embedded domain-specific languages (Functional Programming
eXchange 2012)
 Domain: skillsmatter.com, Score: 31, Comments: 4
 On Reddit: [13] http://goo.gl/pSREX
 Original: [14] http://goo.gl/1azVh

   * Domain theory course
 Domain: cs.nott.ac.uk, Score: 31, Comments: 5
 On Reddit: [15] http://goo.gl/5VHyG
 Original: [16] http://goo.gl/o2pRC

   * ANNOUNCE: options, an easy-to-use command-line option parser
 Domain: self.haskell, Score: 29, Comments: 21
 On Reddit: [17] http://goo.gl/s6ktw
 Original: [18] http://goo.gl/s6ktw

   * A Case Study in Creating Rich Internet Apps in Haskell (Silk at FP
eXchange 2012)
 Domain: skillsmatter.com, Score: 22, Comments: 18
 On Reddit: [19] http://goo.gl/ZdtDq
 Original: [20] http://goo.gl/Ta2HQ

   * It just occurred to me that (lift .) defines a functor...
 Domain: self.haskell, Score: 22, Comments: 15
 On Reddit: [21] http://goo.gl/GMzPt
 Original: [22] http://goo.gl/GMzPt


Top StackOverflow Questions

   * Haskell platform: nested functions and optimization
 votes: 15, answers: 2
 Read on SO: [23] http://goo.gl/nreIr

   * newtype with RankNTypes
 votes: 14, answers: 2
 Read on SO: [24] http://goo.gl/UT9DV

   * Pattern Matching - Prolog Vs Haskell
 votes: 13, answers: 4
 Read on SO: [25] http://goo.gl/3hZV1

   * How does this definition of ArrowLoop.loop work?
 votes: 13, answers: 2
 Read on SO: [26] http://goo.gl/ocSCM

   * Data.Set : does it always know best?
 votes: 12, answers: 2
 Read on SO: [27] http://goo.gl/NUjkB

   * Building a histogram with haskell, many times slower than with python
 votes: 11, answers: 3
 Read on SO: [28] http://goo.gl/kbh5i

   * What is the scope of let when used without in?
 votes: 11, answers: 2
 Read on SO: [29] http://goo.gl/bNwna

   * Strange half to even rounding in different languages [closed]
 votes: 11, answers: 3
 Read on SO: [30] http://goo.gl/lnPch

   * Practical reasons for Сhurch Encoding
 votes: 10, answers: 1
 Read on SO: [31] http://goo.gl/xYoef

   * Can the FFI deal with arrays? If so, how?
 votes: 9, answers: 3
 Read on SO: [32] http://goo.gl/d4R3H


Until next time,
Daniel Santa Cruz

References

   1. http://www.yesodweb.com/blog/2012/03/start-mezzo-haskell
   2.
http://www.reddit.com/r/haskell/comments/r9xdq/starting_the_mezzo_haskell_book/
   3. 

Re: [Haskell-cafe] adding the elements of two lists

2012-03-28 Thread Richard O'Keefe

On 29/03/2012, at 3:08 PM, Doug McIlroy wrote:
 - without newtype
 
 toSeries f = f : repeat 0   -- coerce scalar to series
 
 instance Num a = Num [a] where
   (f:fs) + (g:gs) = f+g : fs+gs
   (f:fs') * gs@(g:gs') = f*g : fs'*gs + (toSeries f)*gs'
 
 - with newtype
 
 newtype Num a = PS a = PS [a] deriving (Show, Eq)
 
 fromPS (PS fs) = fs -- extract list
 toPS f = PS (f : repeat 0)  -- coerce scalar to series
 
 instance Num a = Num (PS a) where
   (PS (f:fs)) + (PS (g:gs)) = PS (f+g : fs+gs)
   (PS (f:fs)) * gPS@(PS (g:gs)) =
  PS $ f*g : fromPS ((PS fs)*gPS + (toPS f)*(PS gs))

Try it again.

newtype PS a = PS [a] deriving (Eq, Show)

u f (PS x)= PS $ map f x
b f (PS x) (PS y) = PS $ zipWith f x y
to_ps x   = PS (x : repeat 0)

ps_product (f:fs) (g:gs) = whatever

instance Num a = Num (PS a)
  where
(+) = b (+)
(-) = b (-)
(*) = b ps_product
negate  = u negate
abs = u abs
signum  = u signum
fromInteger = to_ps . fromInteger

I've avoided defining ps_product because I'm not sure what
it is supposed to do: the definition doesn't look commutative.

 The code suffers a pox of PS.

But it doesn't *need* to.



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


Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-28 Thread Ryan Newton
 GHC already has a CAS primitive on MutVar#, it just needs to be extended
 to MutableArray# and MutableByteArray# (at all of the bit-widths the CAS
 instruction would support, e.g. see readWordXxArray# in
 http://www.haskell.org/ghc/docs/latest/html/libraries/ghc-prim-0.2.0.0/GHC-Prim.html).
 The implementation should be almost identical to casMutVar#.
 In particular I think you need:
 casMutArray# :: MutableArray# s a - Int# - a - a - State# s - (#
 State# s, Int#, a #)
 casWord16MutByteArray :: MutableByteArray# s - Int# - Word# - Word#
 - State# s - (# State# s, Int#, Word#)


FYI, I started working on adding these.  I'm hoping to have it working in
GHC HEAD for any students who need to use it.  To my knowledge the only two
patches required to implement casMutVar# were these two (plus the
preexisting cas() definition in SMP.h):


https://github.com/ghc/ghc/commit/521b792553bacbdb0eec138b150ab0626ea6f36b

https://github.com/ghc/ghc/commit/606f6e1cfcb2e79abaadcc5ed643817d2a4585d8

The latter is a bugfix to the former.

Florian, your proposal looks good to me (
http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/florianhartwig/1).
 You touched on the major things we need to know.

I just read in your proposal that you started looking into the casMutArray#
issue as well.  How far have you gotten with that?  Do you want to work on
this together a bit?

I've got an implementation of a casArray# primop that passes a basic test,
but I'm not sure if the GC write barrier is correct:


https://github.com/rrnewton/ghc/commit/18ed460be111b47a759486677960093d71eef386

The ByteArray versions will be more annoying, requiring more variations,
but they are also less essential, because the user can always use
ForeignPtr and bits-atomic in this case, and I believe for our concurrent
data structures we want to store arbitrary pointers (hence casArray#).

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