Re: [Haskell-cafe] Inputs to classic FRP: unsafeInterleaveIO/unsafePerformIO

2011-04-26 Thread Heinrich Apfelmus

Edward Amsden wrote:

As far as I can tell, with classic FRP implementations (those which
use behaviors as a first-class abstraction), the only way to create a
behavior or
event based on some external input (for instance keypresses or
microphone input) is to do something with unsafePerformIO or
unsafeInterleaveIO. A behavior is a value, which when evaluated at a
specific time would have to either block its evaluation until input
could be read, or check the input at that particular time.

Is there any other way of implementing external behaviors besides that?


Yes, there are other ways, see for example the implementation here: 
http://tinyurl.com/frp-automaton . This is essentially a pure variant of 
Ryan's implementation.


My implementation has a serious problem, namely that sharing is lost. I 
think this is the case for Ryan's implementation as well. The state of a 
behavior will be duplicated and updates multiple times. This can be 
fixed by observing sharing, of course.


I'm currently working on a push-driven FRP implementation. (Though I'm 
getting second thoughts as to whether the small increase in efficiency 
is worth the implementation cost.) See also


http://apfelmus.nfshost.com/blog/2011/04/24-frp-push-driven-sharing.html



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] -- Extension for Pearls of Functional Algorithm Design by Richard Bird, 2010, page 25 #Haskell

2011-04-26 Thread Jason Dagit
Do you have a question for the group or something you want to discuss?

On Mon, Apr 25, 2011 at 8:50 PM, cas...@istar.ca wrote:

 -- Extension for Pearls of Functional Algorithm Design by Richard Bird,
 -- 2010, page 25 #Haskell

 -- This version assumes 3 disjoint ordered sets represented as lists.
 -- So either: xy XOR xy
 -- Since it uses lists it is no faster than the divide and conquer
 approach.

 -- I might try to convert this version to sorted arrays for
 -- O(log|X|+log|Y|+log|Z|) performance
 -- If I can figure out how to do it without suffering from indexitis.



 smallest3'' :: Ord a = Int - ([a], [a], [a]) - a

 smallest3'' k ([],[],ts) = ts !! k
 smallest3'' k (zs,[],[]) = zs !! k
 smallest3'' k ([],ws,[]) = ws !! k

 smallest3'' k ([],ws,ts) = smallest'' k (ws,ts)
 smallest3'' k (zs,[],ts) = smallest'' k (zs,ts)
 smallest3'' k (zs,ws,[]) = smallest'' k (zs,ws)

 smallest3'' k (zs,ws,ts) =
 case (ab, bc, ac) of
 ~~(True, True, True)- smallest3h'' k ((zs,p,ys),(ws,q),(ts,o,rs))
 -- abc
 ~~(True, False, True)   - smallest3h'' k ((zs,p,ys),(ts,o),(ws,q,us))
 -- acb
 ~~(False, True, True)   - smallest3h'' k ((ws,q,vs),(zs,p),(ts,o,rs))
 -- bac
 ~~(False, True, False)  - smallest3h'' k ((ws,q,vs),(ts,o),(zs,p,xs))
 -- bca
 ~~(True, False, False)  - smallest3h'' k ((ts,o,ss),(zs,p),(ws,q,us))
 -- cab
 ~~(False, False, False) - smallest3h'' k ((ts,o,ss),(ws,q),(zs,p,xs))
 -- cba

 where
 ~~p = (length zs) `div` 2
 ~~q = (length ws) `div` 2
 ~~o = (length ts) `div` 2

 ~~(xs, a : ys)  = splitAt p zs
 ~~(us, b : vs)  = splitAt q ws
 ~~(rs, c : ss)  = splitAt o ts

 ~~smallest3h'' k ((zs,p,ys),(ws,q),(ts,o,rs)) =
 case (k=p+q+o) of
 ~~(True)- smallest3'' k (zs,ws,rs)
 ~~(False)   - smallest3'' (k-p-1) (ys,ws,ts)




 smallest'' :: Ord a = Int - ([a], [a]) - a
 smallest'' k ([],ws) = ws !! k
 smallest'' k (zs,[]) = zs !! k
 smallest'' k (zs,ws) =
 case (ab, k=p+q) of
 ~~(True, True)  - smallest'' k (zs,us)
 ~~(True, False) - smallest''(k-p-1) (ys,ws)
 ~~(False, True) - smallest'' k (xs,ws)
 ~~(False, False)- smallest''(k-q-1) (zs,vs)
 where
 ~~p = (length zs) `div` 2
 ~~q = (length ws) `div` 2
 ~~(xs, a : ys)  = splitAt p zs
 ~~(us, b : vs)  = splitAt q ws




 ___
 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] HipmunkPlayground compile error

2011-04-26 Thread Andrew Pennebaker
$ system_profiler SPSoftwareDataType | grep System Version
  System Version: Mac OS X 10.6.7 (10J869)
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.2
$ cabal --version
cabal-install version 0.10.2
using version 1.10.1.0 of the Cabal library
$ cabal install hipmunkplayground
...
Updating documentation index /Users/andrew/Library/Haskell/doc/index.html
cabal: Error: some packages failed to install:
GLFW-0.4.2 failed during the building phase. The exception was:
ExitFailure 1
HipmunkPlayground-5.2.0.3 depends on GLFW-0.4.2 which failed to install.

Cheers,

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


Re: [Haskell-cafe] HipmunkPlayground compile error

2011-04-26 Thread Jason Dagit
On Tue, Apr 26, 2011 at 1:38 AM, Andrew Pennebaker 
andrew.penneba...@gmail.com wrote:

 $ system_profiler SPSoftwareDataType | grep System Version
   System Version: Mac OS X 10.6.7 (10J869)
 $ ghc --version
 The Glorious Glasgow Haskell Compilation System, version 7.0.2
 $ cabal --version
 cabal-install version 0.10.2
 using version 1.10.1.0 of the Cabal library
 $ cabal install hipmunkplayground
 ...
 Updating documentation index /Users/andrew/Library/Haskell/doc/index.html
 cabal: Error: some packages failed to install:
 GLFW-0.4.2 failed during the building phase. The exception was:
 ExitFailure 1
 HipmunkPlayground-5.2.0.3 depends on GLFW-0.4.2 which failed to install.


GLFW is the package that failed to install.  The reason for that should be
in the scroll back somewhere but it can often be hard to find when it's
buried in a huge list of compilation messages.  If you try with just GLFW,
eg., cabal install GLFW, then it should be easier to spot the error.

Since you're on a mac, I would highly recommend getting the latest haskell
platform.  You're on 7.0.2 which has bug fixes that are relevant to build
failures on OSX, as I understand it.

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


Re: [Haskell-cafe] How to keep cabal and ghci package versions in sync?

2011-04-26 Thread Gracjan Polak
Henning Thielemann schlepptop at henning-thielemann.de writes:
 You can manually select packages for GHCi with '-package' option.
 However I do not know a way to automatically syncronise this with the
 dependencies from the Cabal file.
 

I kind of expected 'cabal-dev ghci' to do this for me.

Thanks for help, I'm cleaning my packages for now.

-- 
Gracjan





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


[Haskell-cafe] How to update the RNG per call (State monad) when generating QuickCheck arbitraries?

2011-04-26 Thread Daniel Kahlenberg
Maybe this is a beginners question... But here my problems description:

 import Random
 import Control.Monad
 import qualified Control.Monad.State as S
 import Test.QuickCheck.Gen
 import Test.QuickCheck.Arbitrary

Each thing can have one of three types:

 data Ontology = Thing1 Bool
   | ThingK Bool
   deriving (Show, Eq)

 instance Arbitrary Ontology where
arbitrary =
oneof [ return $ Thing1 True
  , return $ ThingK True
  , return $ Thing1 False
  , return $ ThingK False ]

Liked to have a state monad runner for my arbitrary things as in Real World
Haskell, Chapter 14. Monads (Random values in the state monad).

[RWH]:

 -- file: ch14/Random.hs
 type RandomState a = S.State StdGen a

[RWH]:

 -- file: ch14/Random.hs
 getRandom :: Random a = RandomState a
 getRandom =
   S.get = \gen -
   let (val, gen') = random gen in
   S.put gen' 
   return val

[RWH]:

 -- file: ch14/Random.hs
 getTwoRandoms :: Random a = RandomState (a, a)
 getTwoRandoms = liftM2 (,) getRandom getRandom

[RWH]:

 -- file: ch14/Random.hs
 runTwoRandoms :: IO (Int, Int)
 runTwoRandoms = do
   oldState - getStdGen
   let (result, newState) = S.runState getTwoRandoms oldState
   setStdGen newState
   return result

Thought getRandom function would be the best place to inject my unGen function
call, but cannot get it to type-check:

 getRandom :: Random a = RandomState [a]
 getRandom =
   S.get = \gen -
   let (val, gen') = liftM2 (,) (unGen arbitrary gen 12) (random gen) in
   S.put gen' 
   return val

A function not almost fulfilling my needs but the Random Number Generator isn't
updated... I liked to have different [Ontology] occasions per call:

 genArray :: [Ontology]
 genArray = unGen arbitrary (mkStdGen 42) 12 :: [Ontology]

Does anyone have the patience to help me out at least one step further?

Cheers
Daniel

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


[Haskell-cafe] Why does Cabal not choose the latest package?

2011-04-26 Thread Emil Axelsson

Hello!

I've had some of the usual problems with packages depending on multiple 
versions of another package. It seems the root of the hole problem was 
that I once attempted to run


  cabal install cabal-install

This brought in a number of older packages (Cabal-1.8.0.6, 
containers-0.3.0.0, directory-1.0.1.2, filepath-1.1.0.4, 
process-1.0.1.5) to my local package DB, which led to inconsistencies 
when trying to install new packages.


However, if I run

  cabal install cabal-install-0.10.2

things work just fine. So the problem is that it wants to install an 
older version of cabal-install. A session demonstrating the problem is 
found below.


Why doesn't cabal always install the latest packages?

Thanks!

/ Emil


[emax@laptop:~] ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.2

[emax@laptop:~] cabal --version
cabal-install version 0.10.2
using version 1.10.1.0 of the Cabal library

[emax@laptop:~] cabal install cabal-install
Resolving dependencies...
Downloading containers-0.3.0.0...
...

[emax@laptop:~] cabal install cabal-install-0.10.2
Resolving dependencies...
Configuring cabal-install-0.10.2...
Preprocessing executables for cabal-install-0.10.2...
Building cabal-install-0.10.2...
...


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


Re: [Haskell-cafe] Why does Cabal not choose the latest package?

2011-04-26 Thread Jason Dagit
On Tue, Apr 26, 2011 at 3:22 AM, Emil Axelsson e...@chalmers.se wrote:

 Hello!

 I've had some of the usual problems with packages depending on multiple
 versions of another package. It seems the root of the hole problem was that
 I once attempted to run

  cabal install cabal-install

 This brought in a number of older packages (Cabal-1.8.0.6,
 containers-0.3.0.0, directory-1.0.1.2, filepath-1.1.0.4, process-1.0.1.5) to
 my local package DB, which led to inconsistencies when trying to install new
 packages.

 However, if I run

  cabal install cabal-install-0.10.2

 things work just fine. So the problem is that it wants to install an older
 version of cabal-install. A session demonstrating the problem is found
 below.

 Why doesn't cabal always install the latest packages?


I consider this a bug but it's actually an intentional feature by the cabal
developers.  I explained it in the past here:
http://osdir.com/ml/haskell-cafe@haskell.org/2010-09/msg00758.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] converting prefixes of CString - String

2011-04-26 Thread Malcolm Wallace

On 25 Apr 2011, at 08:16, Eric Stansifer wrote:

 Let 'c2h' convert CStrings to Haskell Strings, and 'h2c' convert
 Haskell Strings to CStrings.  (If I understand correctly, c2h . h2c
 === id, but h2c . c2h is not the identity on all inputs;

That is correct.  CStrings are 8-bits, and Haskell Strings are 32-bits.  
Converting from Haskell to C loses information, unless you use a multi-byte 
encoding on the C side (for instance, UTF8).

  or perhaps c2h is not defined for all CStrings.

Rather, h2c is not necessarily well-defined for all Haskell Strings.  In 
particular, the marshalling functions in Foreign.C.String simply truncate any 
character larger than one byte, to its lowest byte.

I suggest you look at the utf8-string package, for instance 
Codec.Binary.UTF8.String.{encode,decode}, which convert Haskell strings to/from 
a list of Word8, which can then be transferred via the FFI to wherever you like.

Regards,
Malcolm

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


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-26 Thread Malcolm Wallace

On 25 Apr 2011, at 11:13, Andrew Coppin wrote:

 On 24/04/2011 06:33 PM, Jason Dagit wrote:
 
 This is because of a deliberate choice that was made by David Roundy.
 In darcs, you never have multiple branches within a single darcs
 repository directory tree.
 
 Yes, this seems clear. I'm just wondering whether or not it's the best design 
 choice.

It seems to me to be a considerable insight.  Branches and repositories are the 
same thing.  There is no need for two separate concepts.  The main reason other 
VCSes have two concepts is because one of them is often more efficiently 
implemented (internally) than the other.  But that's silly - how much better to 
abstract over the mental clutter, and let the implementation decide how its 
internals look!

So in darcs, two repositories on the same machine share the same files (like a 
branch), but if they are on different machines, they have separate copies of 
the files.  The difference is a detail that you really don't need to know or 
care about.

 It does mean that you duplicate information. You have [nearly] the same set 
 of patches stored twice,

No, if on the same machine, the patches only appear once, it is just the index 
that duplicates some information (I think).  In fact just as if it were a 
branch in another VCS.

Regards,
Malcolm

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


Re: [Haskell-cafe] plugins and cabal build

2011-04-26 Thread Ivan Lazar Miljenovic
On 26 April 2011 04:57, Michael Snoyman mich...@snoyman.com wrote:
 Hi all,

 I'm experimenting with using the plugins package for yesod devel
 server. The basic approach is to use cabal for building the object
 files, and then load them with plugins. I can get everything to work
 when I compile with ghc --make, but I believe name mangling is
 getting in the way with the cabal build route. Can someone give some
 guidance on how to properly mangle the function names so that plugins
 can load them?

I'm not sure if he reads this list, but Andy Stewart might know (and
I've CC'd him to this).

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

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


[Haskell-cafe] Wai and http-enumerator not as lazy as I'd like

2011-04-26 Thread Erik de Castro Lopo
Hi all,

I'm using Wai and http-enumerator to build a http proxy. The core of
the code looks like this:

import qualified Network.HTTP.Enumerator as HE
import qualified Network.Wai as Wai

serveRequest :: forall (m :: * - *).
 (MonadControlIO m, Failure HE.HttpException m) =
 HE.Request m - m Wai.Response
serveRequest request
 = do   HE.Response sc rh bs - HE.withManager $ HE.httpLbsRedirect request
return $ Wai.responseLBS (mkStatus sc) rh bs

This works but does not run in constant space as I would have hoped.
The thing is, HE.httpLbsRedirect returns a lazy ByteString and
Wai.responseLBS writes a lazy ByteString, so why isn't the whole thing
lazy?

I'd appreciate any clues.

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

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


Re: [Haskell-cafe] converting prefixes of CString - String

2011-04-26 Thread Eric Stansifer
 Let 'c2h' convert CStrings to Haskell Strings, and 'h2c' convert
 Haskell Strings to CStrings.  (If I understand correctly, c2h . h2c
 === id, but h2c . c2h is not the identity on all inputs;

 That is correct.  CStrings are 8-bits, and Haskell Strings are 32-bits.  
 Converting from Haskell to C loses information, unless you use a multi-byte 
 encoding on the C side (for instance, UTF8).

So actually I am incorrect, and h2c . c2h is the identity but c2h . h2c is not?

 I suggest you look at the utf8-string package, for instance 
 Codec.Binary.UTF8.String.{encode,decode}, which convert Haskell strings 
 to/from a list of Word8, which can then be transferred via the FFI to 
 wherever you like.

This package was very helpful;  I looked at the source to see how the
utf8 encoding was done.  It looks as if the functionality I want is
technically feasible but not implemented yet;  it shouldn't be too
much trouble to implement it myself, by imitating the existing
'decode' function but changing its behavior when it runs out of input
in the middle of a utf8-character.  Also key is the property
s1 ++ s2 == decode (encode s1)) ++ decode (encode s2))
holds.

Thanks,
Eric

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


Re: [Haskell-cafe] Wai and http-enumerator not as lazy as I'd like

2011-04-26 Thread Antoine Latter
On Tue, Apr 26, 2011 at 7:27 AM, Erik de Castro Lopo
mle...@mega-nerd.com wrote:
 Hi all,

 I'm using Wai and http-enumerator to build a http proxy. The core of
 the code looks like this:

    import qualified Network.HTTP.Enumerator     as HE
    import qualified Network.Wai                 as Wai

    serveRequest :: forall (m :: * - *).
             (MonadControlIO m, Failure HE.HttpException m) =
             HE.Request m - m Wai.Response
    serveRequest request
     = do   HE.Response sc rh bs - HE.withManager $ HE.httpLbsRedirect request
            return $ Wai.responseLBS (mkStatus sc) rh bs

 This works but does not run in constant space as I would have hoped.
 The thing is, HE.httpLbsRedirect returns a lazy ByteString and
 Wai.responseLBS writes a lazy ByteString, so why isn't the whole thing
 lazy?


None of the lbs functions in http-enumerator can operate in constant
space - they are all built on top of the utility function lbsIter
which provides a warning:

 Convert the HTTP response into a Response value.

 Even though a Response contains a lazy bytestring, this function does not 
 utilize lazy
 I/O, and therefore the entire response body will live in memory. If you want 
 constant 
 memory usage, you'll need to write your own iteratee and use http or 
 httpRedirect
 directly.

See:

http://hackage.haskell.org/packages/archive/http-enumerator/0.6.0.2/doc/html/Network-HTTP-Enumerator.html#g:4

It might be good to have this warning on the functions that use
lbsIter, or have them use ByteStrings instead of Lazy ByteStrings.

Antoine

 I'd appreciate any clues.

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

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


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


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-26 Thread Andrew Coppin

This is because of a deliberate choice that was made by David Roundy.
In darcs, you never have multiple branches within a single darcs
repository directory tree.


Yes, this seems clear. I'm just wondering whether or not it's the best design 
choice.


It seems to me to be a considerable insight.


Presumably David thought the same. I won't deny that there is a certain 
simplifying elegance to it.



It does mean that you duplicate information. You have [nearly] the same set of 
patches stored twice,


No, if on the same machine, the patches only appear once, it is just the index 
that duplicates some information (I think).  In fact just as if it were a 
branch in another VCS.


1. Conceptually, you have the same information twice.

2. I have no idea how to make Darcs do the thing with hard links (is 
that even supported under Windows?) I just copy the whole folder using 
the normal OS file tools.


Either way, you lose the ability to see how branches are related to each 
other, which might be useful in some cases.


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


Re: [Haskell-cafe] ANN: Leksah 0.10.0

2011-04-26 Thread Daniel Fischer
On Tuesday 26 April 2011 02:00:32, jutaro wrote:
 Well, it is a bit more intricate to invert the sides. After
 * swapping LeftP and RightP in Edit Prefs - Initial Pane positions
 * Close all panes and pane groups. (You may leave an editor window open,
 so that you better see what happens in the next steps).
 * Collapse all (Hit Ctrl-1 - 2 times)
 * Split vertical (Hit Ctrl-2), put the focus to the left, split
 horizontal (Hit Ctrl-3)
 * Go to Panes Menu and reopen the Log and the Browser and an editor
 Window * Configure tabs as you like
 * Save the session or restart Leksah
 

Intricate indeed. If some day you have too much time, consider adding 
configuration options for that. Until then, how about putting that in the 
docs?

  How do I configure autocompletion to only begin after three or four
  letters
  have been typed?
 
 Go to Edit Prefs - GUI Options, and select Complete only on Hotkey,
 then hit
 Ctrl-Space if you want completion.
 

Not ideal (for me), but good enough I think. Although, I find kate's 
configuration option to start autocompletion after n letters *very* nice.

 Daniel Fischer wrote:
  Decreasing indentation via backspace goes one column per backspace,
  how can
  I configure it to go to the next (previous) tab position on backspace
  in the leading whitespace of a line?
 
 You can't do this currently, but you can post a wish for enhancement to
 our issue tracker.
 

Pity. 
Quoth Hamish:
 shifttab works, but it is a bit dumb.
 
 Changing backspace is on my wish list too.  I think we should make
 it look at the text above to find the correct indentation points.

So there's initial support for it, good sign.

 
 Please try to run Leksah with the default config
 (~/.leksah-0.10/packageSources)
 

Will do. Unfortunately I had to wipe the old OS from disk and now have to 
rebuild a couple of GHCs and a load of libraries (different gmp version), 
that'll take a while.


 
 Indeed leksah may use more memory on the first run

That's natural, collecting the data isn't free.

 (actually it is ghc, which uses it).

I'm not sure about that. According to top, leksah-server used that much 
memory long after ghc ran last. And on the second start, it didn't invoke 
ghc (at least, no ghc was reported by top). Looks a bit as though it 
doesn't write the data soon enough. Or it could have been the first sign of 
my OS crashing.

 But on consecutive starts it may use about/up to 150MB, but not the
 numbers you give.

That's more reasonable. We'll see.

 So please try to run Leksah with the default config, and see if the
 problem remains.

Yes, but as mentioned above, that'll not be immediately.

 
 Jürgen

Thanks,
Daniel

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


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-26 Thread Ivan Lazar Miljenovic
On 26 April 2011 13:16, Andrew Coppin andrewcop...@btinternet.com wrote:

 2. I have no idea how to make Darcs do the thing with hard links (is that
 even supported under Windows?) I just copy the whole folder using the normal
 OS file tools.

darcs get path/to/other/local/repo

 Either way, you lose the ability to see how branches are related to each
 other, which might be useful in some cases.

How do you see how git branches are related to each other?

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

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


Re: [Haskell-cafe] converting prefixes of CString - String

2011-04-26 Thread Malcolm Wallace

On 26 Apr 2011, at 13:31, Eric Stansifer wrote:

 Let 'c2h' convert CStrings to Haskell Strings, and 'h2c' convert
 Haskell Strings to CStrings.  (If I understand correctly, c2h . h2c
 === id, but h2c . c2h is not the identity on all inputs;
 
 That is correct.  CStrings are 8-bits, and Haskell Strings are 32-bits.  
 Converting from Haskell to C loses information, unless you use a multi-byte 
 encoding on the C side (for instance, UTF8).
 
 So actually I am incorrect, and h2c . c2h is the identity but c2h . h2c is 
 not?

Ah, my bad.  In reading the composition from right to left, I inadvertently 
read h2c and c2h from right to left as well!  So, starting from C, converting 
to Haskell, and back to C is the identity, yes.  Starting from Haskell, no.

Regards,
Malcolm

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


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-26 Thread Jason Dagit
On Tue, Apr 26, 2011 at 6:35 AM, Ivan Lazar Miljenovic 
ivan.miljeno...@gmail.com wrote:

 On 26 April 2011 13:16, Andrew Coppin andrewcop...@btinternet.com wrote:
 
  2. I have no idea how to make Darcs do the thing with hard links (is
 that
  even supported under Windows?) I just copy the whole folder using the
 normal
  OS file tools.

 darcs get path/to/other/local/repo


More specifically than that.  This is the workflow I follow with darcs
repos.  Say, that I want to get the Foo repo:
mkdir ~/repos/Foo
cd ~/repos/Foo
darcs get http://example.com/Foo HEAD
darcs get HEAD feature-branch

Then I can send the patches from feature-branch to the official Foo repo at
any time.  I can also merge them back into HEAD doing a darcs pull from
feature-branch to HEAD.

I think this is quite comparable to the git workflow.



  Either way, you lose the ability to see how branches are related to each
  other, which might be useful in some cases.

 How do you see how git branches are related to each other?


You can use gitk to see how the histories have interacted.

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


Re: [Haskell-cafe] There is no null; Maybe/Option types

2011-04-26 Thread Ertugrul Soeylemez
wren ng thornton w...@freegeek.org wrote:

 But the greatest thing about Maybe is that you don't *have* to write
 code in monadic style. Because Maybe makes explicit the null-pointer
 shenanigans in other languages, you can simply unwrap the Maybe and
 pass around the raw value instead of letting Nothing permeate your
 whole program. Spending all your time in the Maybe monad is just as
 bad as spending all your time in the IO monad.

Unless you're saying that I'm one of the worst Haskell programmers in
the world, you are totally wrong.  Monads are an abstraction for
convenience and beauty in expression, not for encapsulating bad habits.
Particularly there is nothing wrong with writing 90% of your code in
monadic style, which is what I do, often combining three or more monads.

And even if I don't use Maybe in monadic style, I often use combinators
like 'maybe'.  Monadic style to avoid explicit wrapping, and combinators
to avoid explicit unwrapping.

What exactly is wrong with that?  Why would you /not/ use (=) to
calculate the fourth root from a monadic square root function?

  fourthRoot :: (Alternative f, Integral i, Monad f) = i - f i
  fourthRoot = mSqrt = mSqrt


 Purity begets clarity!

All Haskell code is pure (in the sense of referential transparency),
including monadic code, even in the IO monad.


Greets,
Ertugrul


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



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


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-26 Thread Daniel Fischer
On Tuesday 26 April 2011 15:35:42, Ivan Lazar Miljenovic wrote:
 How do you see how git branches are related to each other?

To some extent, you can see such a relation in gitk. For mercurial, hg glog 
also shows a bit. I suppose there's also something to visualise branches in 
bazaar, but I've never used that, so I don't know.

So, with gitk/glog, you can see that foo branched off bar after commit 
0de8793fa1bc..., then checkout/update to that commit [or bar's head], 
checkout/update to foo's head/tip and compare.

Or there could be some feature I've never heard of yet.

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


Re: [Haskell-cafe] plugins and cabal build

2011-04-26 Thread Andy Stewart
Ivan Lazar Miljenovic ivan.miljeno...@gmail.com writes:

 On 26 April 2011 04:57, Michael Snoyman mich...@snoyman.com wrote:
 Hi all,

 I'm experimenting with using the plugins package for yesod devel
 server. The basic approach is to use cabal for building the object
 files, and then load them with plugins. I can get everything to work
 when I compile with ghc --make, but I believe name mangling is
 getting in the way with the cabal build route. Can someone give some
 guidance on how to properly mangle the function names so that plugins
 can load them?

 I'm not sure if he reads this list, but Andy Stewart might know (and
 I've CC'd him to this).
Hi Ivan, sorry for late, too busy on Linux job.

Yes, i have got hot-swap code work for Manatee
(http://hackage.haskell.org/package/manatee)

I used to use plugins, but i found it's buggy.
So i use GHC-API wrote my own code at:
https://patch-tag.com/r/AndyStewart/manatee-core/snapshot/current/content/pretty/Manatee/Core/Dynload.hs

Michael, from your need, you just need read function `dynload`, other
functions is write for Manatee framework.

Let me explain function `dynload`:

dynload :: (String, String, [(String, HValue - IO ())]) - IO ()
dynload (filepath, moduleName, loadList) = ...

First argument is FilePath that contain module.
Second argument is moduleName you need scan.
Third argument is tuple list that contain symbol you need load and
callback function for symbol's HValue.

Once function `dynload` find symbol in target module, it will use below code
dynamic load new value:

(do
hValue - compileExpr (moduleName ++ . ++ symbolName)
liftIO $ loadFun hValue)

function `compileExpr` will get the HValue of symbol, then use loadFun
update HVaule in running program.

The key is `HValue - IO ()`, you need build TVar/IORef in your
running program, once you got new HValue, you should write
writeTVar/writeIORef in function `HValue - IO ()` to update the value of
TVar/IORef, then you can dynamic loading new value and don't need
reboot.

I have draw some picture to explain above framework:
http://www.flickr.com/photos/48809572@N02/5304662424/in/photostream/lightbox/

Michael, hope above will help you, good luck! :)

  -- Andy

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


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-26 Thread Nick Bowler
On 2011-04-26 15:51 +0200, Daniel Fischer wrote:
 On Tuesday 26 April 2011 15:35:42, Ivan Lazar Miljenovic wrote:
  How do you see how git branches are related to each other?
 
 To some extent, you can see such a relation in gitk. For mercurial, hg glog 
 also shows a bit. I suppose there's also something to visualise branches in 
 bazaar, but I've never used that, so I don't know.
 
 So, with gitk/glog, you can see that foo branched off bar after commit 
 0de8793fa1bc..., then checkout/update to that commit [or bar's head], 
 checkout/update to foo's head/tip and compare.

No need to do a checkout; gitk can visualize any or all branches of the
repository simultaneously.

-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)

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


Re: [Haskell-cafe] Question about the Monad instance for Iteratee (from the enumerator package)

2011-04-26 Thread John Lato
Joining slightly late...


 From: John Millikin jmilli...@gmail.com

 John Lato's iteratee package is based on IterateeMCPS.hs[1]. I used
 IterateeM.hs for enumerator, because when I benchmarked them the non-CPS
 version was something like 10% faster on most operations.


Based on tests I did before iteratee-0.4, the fastest implementation was
Oleg's alternate design which is in the comments of IterateeM.hs.  I don't
think any current packages use that however, with good reason.

I'd be interested to see the results of a shootout between iteratee and
enumerator.  I would expect them to be basically equivalent most of the
time, with maybe two or three operations with a small (but consistent)
difference one way or the other.

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


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-26 Thread Daniel Fischer
On Tuesday 26 April 2011 16:04:55, Nick Bowler wrote:
 On 2011-04-26 15:51 +0200, Daniel Fischer wrote:
  On Tuesday 26 April 2011 15:35:42, Ivan Lazar Miljenovic wrote:
   How do you see how git branches are related to each other?
  
  To some extent, you can see such a relation in gitk. For mercurial, hg
  glog also shows a bit. I suppose there's also something to visualise
  branches in bazaar, but I've never used that, so I don't know.
  
  So, with gitk/glog, you can see that foo branched off bar after commit
  0de8793fa1bc..., then checkout/update to that commit [or bar's head],
  checkout/update to foo's head/tip and compare.
 
 No need to do a checkout; gitk can visualize any or all branches of the
 repository simultaneously.

Yes, at least if you're only interested in the genealogy.
When I think about how branches are related, I think of contents at least 
as much as of genealogy. Can gitk show the code next to each other?
I wouldn't be surprised, but I haven't yet found a way to do it (but I've 
only taken a couple of short looks, so that doesn't say much).

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


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-26 Thread Radoslav Dorcik
On Tue, Apr 26, 2011 at 3:16 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
 Presumably David thought the same. I won't deny that there is a certain
 simplifying elegance to it.

 It does mean that you duplicate information. You have [nearly] the same
 set of patches stored twice,

 No, if on the same machine, the patches only appear once, it is just the
 index that duplicates some information (I think).  In fact just as if it
 were a branch in another VCS.

 1. Conceptually, you have the same information twice.

 2. I have no idea how to make Darcs do the thing with hard links (is that
 even supported under Windows?) I just copy the whole folder using the normal
 OS file tools.

 Either way, you lose the ability to see how branches are related to each
 other, which might be useful in some cases.

http://wiki.darcs.net/Ideas/Branches

I would like to have in-place Darcs branches too but not for wasting
space reason.
It is nice to keep complete history of the project and with current
loose coupling of branches it requires more discipline from me :)

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


[Haskell-cafe] typing hmatrix expressions

2011-04-26 Thread Carter Schonwald
hello alberto,
i've had some funny issues with using the cmap function, and i'd like
understand what i'm doing wrong
namely it wont correctly instantiate for vectors or matrices and I don't
understand why.

basically my question  is:

what is the correct type for the hmatrix expression

mapMat f  =liftMatrix $! cmap f


I'd like to just give it a type like
Storable a = (a-a)- Matrix a - Matrix a

but i get an error message like
Electrical.lhs:89:29:
No instance for (Container Vector e0)
  arising from a use of `cmap'
Possible fix: add an instance declaration for (Container Vector e0)
In the second argument of `($!)', namely `cmap f'
In the expression: liftMatrix $! cmap f
In an equation for `mapMat': mapMat f = liftMatrix $! cmap f

which i feel shouldn't be happening.

is the type of cmap in some way too polymorphic, or am I just not turning on
the right ghc type extensions for this to work,
or is this something that would have been well typed prior to ghc 7? Or am i
just not correctly understanding this type error and i'm making a simple
mistake?

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


Re: [Haskell-cafe] How to update the RNG per call (State monad) when generating QuickCheck arbitraries?

2011-04-26 Thread Bryan O'Sullivan
On Tue, Apr 26, 2011 at 3:04 AM, Daniel Kahlenberg 
d.kahlenb...@googlemail.com wrote:

 Thought getRandom function would be the best place to inject my unGen
 function
 call, but cannot get it to type-check:


You haven't described what it is you're actually trying to do, and I'm
afraid your code doesn't help to understand that.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-26 Thread Maciej Marcin Piechotka
On Tue, 2011-04-26 at 16:34 +0200, Daniel Fischer wrote:
 On Tuesday 26 April 2011 16:04:55, Nick Bowler wrote:
  On 2011-04-26 15:51 +0200, Daniel Fischer wrote:
   On Tuesday 26 April 2011 15:35:42, Ivan Lazar Miljenovic wrote:
How do you see how git branches are related to each other?
   
   To some extent, you can see such a relation in gitk. For mercurial, hg
   glog also shows a bit. I suppose there's also something to visualise
   branches in bazaar, but I've never used that, so I don't know.
   
   So, with gitk/glog, you can see that foo branched off bar after commit
   0de8793fa1bc..., then checkout/update to that commit [or bar's head],
   checkout/update to foo's head/tip and compare.
  
  No need to do a checkout; gitk can visualize any or all branches of the
  repository simultaneously.
 
 Yes, at least if you're only interested in the genealogy.
 When I think about how branches are related, I think of contents at least 
 as much as of genealogy. Can gitk show the code next to each other?
 I wouldn't be surprised, but I haven't yet found a way to do it (but I've 
 only taken a couple of short looks, so that doesn't say much).

I cannot say for gitk but gitview does it does it for sure:

gitview --all --date-order

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to update the RNG per call (State monad) when generating QuickCheck arbitraries?

2011-04-26 Thread Bryan O'Sullivan
On Tue, Apr 26, 2011 at 9:16 AM, Daniel Kahlenberg
d.kahlenb...@gmail.comwrote:


 hold on I'd like to have the genArray call generating distinctive
 results in one IO execution


The problem you're seeing is due to the fact that you're not taking the
final RNG state from the first execution of your code and passing it as the
initial state to the second. Since you're initialising each one with the
same RNG state, you're getting the same results in each case.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to keep cabal and ghci package versions in sync?

2011-04-26 Thread Rogan Creswick
On Tue, Apr 26, 2011 at 2:10 AM, Gracjan Polak gracjanpo...@gmail.com wrote:

 I kind of expected 'cabal-dev ghci' to do this for me.

At the moment, cabal-dev ghci just uses the -package-conf and
-no-user-package-conf flags to restrict ghci to the sandboxed and
global package dbs.

It's difficult to do more without parsing the content of the project's
cabal file, and that parser isn't exposed through a library api (it's
in cabal-install), which makes it a little difficult to use.

--Rogan

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


Re: [Haskell-cafe] Question about the Monad instance for Iteratee (from the enumerator package)

2011-04-26 Thread John Millikin
On Tuesday, April 26, 2011 7:19:25 AM UTC-7, John Lato wrote:

 I'd be interested to see the results of a shootout between iteratee and 
 enumerator.  I would expect them to be basically equivalent most of the 
 time, with maybe two or three operations with a small (but consistent) 
 difference one way or the other.


I did some basic benchmarks a few months ago; if I remember correctly, it 
depends almost entirely on how well GHC optimizes CPS on a particular 
platform. The relative performace was very similar to Lennart Kolmodin's 
benchmarks of binary at  
http://lennartkolmodin.blogspot.com/2011/02/binary-by-numbers.html . In 
particular, CPS/iteratee is faster on 32-bit, while state 
passing/enumerator is faster on 64-bit.

This difference exists for almost all operations, and was on the order of 
5-15% depending on the shape of the input. I couldn't figure out a good way 
to benchmark the libraries themselves when there's so much noise from the 
compiler.

I'm waiting for GHC7 to stabilise a bit before doing another benchmark -- 
the LLVM backend and new CPS handling should make both implementations 
faster, once they're a bit more mature. I really hope CPS becomes as fast on 
64-bit as it is on 32-bit, because it's a much cleaner implementation.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: cereal-0.3.3.0

2011-04-26 Thread Trevor Elliott
Hot on the heels of the last release, cereal-0.3.3.0 [1] adds support
for parsing and rendering lazy ByteStrings.  Most running functions in
Data.Serialize.Get and Data.Serialize.Put now have lazy analogues, and
Data.Serialize has gained encodeLazy and decodeLazy.

This new functionality was made possible by the incremental parsing
support added in cereal-0.3.1.0 by Lemmih.

[1] http://hackage.haskell.org/package/cereal-0.3.3.0



smime.p7s
Description: S/MIME Cryptographic Signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell User Group starter kit

2011-04-26 Thread Eric Y. Kow
Hi all,

We may be coming to a time where we start to see Haskell User Groups or
Functional Programming clubs popping up all the over the place.  Maybe
it's a good time to put our heads together and figure out what we can do
to nurture these groups, to keep them going strong rather than fizzling
out.

One idea might be create some sort of Haskell User Group starter kit
so that individual groups can hit the ground running with some
concrete ideas.

  http://www.haskell.org/haskellwiki/Haskell_User_Group

My hope is that it would provide just enough material for a group to
reach critical mass.  So just enough stuff to account for the different
kinds of activities a HUG may want to do (eg. Coding Dojos vs Talks vs
Reading Group), but not so much that HUGs feel intimidated or stifled.

Have you started a HUG recently? Or are you thinking of starting one?
Maybe you could contribute just one idea to the kit?  More welcome,
of course :-)

-- 
Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow
For a faster response, try +44 (0)1273 64 2905 or
xmpp:ko...@jabber.fr (Jabber or Google Talk only)


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


Re: [Haskell-cafe] Haskell User Group starter kit

2011-04-26 Thread aditya siram
Yes! This is a great idea.

I'm a Haskell enthusiast in St. Louis, MO, USA and have given numerous
talks on Haskell locally at Lambda Lounge[1], a catch-all groups for
functional programmers, and the St.Louis Perl Mongers[2].

I would love to have a dedicated Haskell User Group, but unfortunately
this town appears to run on the JVM and I haven't been able to drum up
too much interest by myself. I've also never started or run a user
group before and I am also not the greatest salesman so some pointers
on how to create a buzz would be helpful.

-deech

[1] lambdalounge.org
[2] http://stlouis.pm.org/

On Tue, Apr 26, 2011 at 12:47 PM, Eric Y. Kow eric@gmail.com wrote:
 Hi all,

 We may be coming to a time where we start to see Haskell User Groups or
 Functional Programming clubs popping up all the over the place.  Maybe
 it's a good time to put our heads together and figure out what we can do
 to nurture these groups, to keep them going strong rather than fizzling
 out.

 One idea might be create some sort of Haskell User Group starter kit
 so that individual groups can hit the ground running with some
 concrete ideas.

  http://www.haskell.org/haskellwiki/Haskell_User_Group

 My hope is that it would provide just enough material for a group to
 reach critical mass.  So just enough stuff to account for the different
 kinds of activities a HUG may want to do (eg. Coding Dojos vs Talks vs
 Reading Group), but not so much that HUGs feel intimidated or stifled.

 Have you started a HUG recently? Or are you thinking of starting one?
 Maybe you could contribute just one idea to the kit?  More welcome,
 of course :-)

 --
 Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow
 For a faster response, try +44 (0)1273 64 2905 or
 xmpp:ko...@jabber.fr (Jabber or Google Talk only)

 ___
 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] Question about the Monad instance for Iteratee (from the enumerator package)

2011-04-26 Thread John Lato
On Tue, Apr 26, 2011 at 6:32 PM, John Millikin jmilli...@gmail.com wrote:

 On Tuesday, April 26, 2011 7:19:25 AM UTC-7, John Lato wrote:

 I'd be interested to see the results of a shootout between iteratee and
 enumerator.  I would expect them to be basically equivalent most of the
 time, with maybe two or three operations with a small (but consistent)
 difference one way or the other.


 I did some basic benchmarks a few months ago; if I remember correctly, it
 depends almost entirely on how well GHC optimizes CPS on a particular
 platform. The relative performace was very similar to Lennart Kolmodin's
 benchmarks of binary at 
 http://lennartkolmodin.blogspot.com/2011/02/binary-by-numbers.html . In
 particular, CPS/iteratee is faster on 32-bit, while state
 passing/enumerator is faster on 64-bit.

 This difference exists for almost all operations, and was on the order of
 5-15% depending on the shape of the input. I couldn't figure out a good way
 to benchmark the libraries themselves when there's so much noise from the
 compiler.


That figures.  Thanks for sharing this.

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


Re: [Haskell-cafe] Inputs to classic FRP: unsafeInterleaveIO/unsafePerformIO

2011-04-26 Thread Ryan Ingram
Apfelmus, I hope you don't abandon your efforts, at least for the selfish
reason that I enjoy reading your blog entries about trying to implement it!

I was looking at your last entry and trying to understand if/how you solve
the order-dependency problem for events.  In particular:

source events e1, e2

e3 = e1 union e2
e4 = e2 union e1

e5 = e3 union e4

The graph from your description would look something like


e1  e2
| \-A  / \   A-\
e3e3 e4e4
| |   ||
e5e5 e5e5

When I was looking at the FRP problem before, it felt a lot like the
'adaptive' problem, so I was looking at Umut Acar's papers and trying to
build something along those lines.  But perhaps your API is simple enough
that you don't need that degree of complexity.

  -- ryan

On Tue, Apr 26, 2011 at 12:29 AM, Heinrich Apfelmus 
apfel...@quantentunnel.de wrote:

 Edward Amsden wrote:

 As far as I can tell, with classic FRP implementations (those which
 use behaviors as a first-class abstraction), the only way to create a
 behavior or
 event based on some external input (for instance keypresses or
 microphone input) is to do something with unsafePerformIO or
 unsafeInterleaveIO. A behavior is a value, which when evaluated at a
 specific time would have to either block its evaluation until input
 could be read, or check the input at that particular time.

 Is there any other way of implementing external behaviors besides that?


 Yes, there are other ways, see for example the implementation here:
 http://tinyurl.com/frp-automaton . This is essentially a pure variant of
 Ryan's implementation.

 My implementation has a serious problem, namely that sharing is lost. I
 think this is the case for Ryan's implementation as well. The state of a
 behavior will be duplicated and updates multiple times. This can be fixed by
 observing sharing, of course.

 I'm currently working on a push-driven FRP implementation. (Though I'm
 getting second thoughts as to whether the small increase in efficiency is
 worth the implementation cost.) See also

 http://apfelmus.nfshost.com/blog/2011/04/24-frp-push-driven-sharing.html



 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] A small Darcs anomoly

2011-04-26 Thread Sergei Trofimovich
  2. I have no idea how to make Darcs do the thing with hard links (is that
  even supported under Windows?) I just copy the whole folder using the normal
  OS file tools.
 
 darcs get path/to/other/local/repo
 
  Either way, you lose the ability to see how branches are related to each
  other, which might be useful in some cases.
 
 How do you see how git branches are related to each other?

git show-branch [branches]

It was one of nicest things in git for me when I stared to use it.

xmms2-devel $ git show-branch
! [error-on-implicit] OTHER: wscript: make implicit function declarations an 
error in C code
 * [master] FEATURE(2184): Update pre-generated cython files.
  ! [missing-protos] OTHER: one more me in AUTHORS
---
+   [error-on-implicit] OTHER: wscript: make implicit function declarations an 
error in C code
  + [missing-protos] OTHER: one more me in AUTHORS
  + [missing-protos^] OTHER: explicitely declare g_sprintf()
  + [missing-protos~2] OTHER: explicitely declare semtimedop()
+*+ [master] FEATURE(2184): Update pre-generated cython files.

The simpler things are:
git [log|diff] from..to
git [log|diff] from...to

Set of [commits|changes] to be added to another branch.

-- 

  Sergei


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


Re: [Haskell-cafe] ANNOUNCE: iteratee-compress 0.2.0.0

2011-04-26 Thread Maciej Piechotka
On Mon, 2011-04-25 at 15:47 +0900, Conrad Parker wrote:
 On 23 April 2011 19:29, Maciej Piechotka uzytkown...@gmail.com wrote:
  Iteratee-compress provides compressing and decompressing enumerators
  including flushing (using John Lato's implementation). Currently only
  gzip and bzip is provided but LZMA is planned.
 
  Changes from previous version:
   - Add BZip support
 
 
 Cool :)
 
 I notice the haddocks on hackage have not been generated; would this
 be due to libbz2-dev missing on the hackage server?
 
 Conrad.

No - you need to wait as it is a batch process. Currently it is
up-to-date.

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HipmunkPlayground compile error

2011-04-26 Thread Andrew Pennebaker
Thanks for the tip. GHC 7.0.3 does seem to fix a couple bugs, and maybe even
run faster than GHC 7.0.2.

But it doesn't solve the problem.

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.3
$ cabal --version
cabal-install version 0.10.2
using version 1.10.1.0 of the Cabal library
$ cabal install hipmunk
(works)
$ cabal install hipmunkplayground
(dozens of GLFW warnings)
...
Updating documentation index /Users/andrew/Library/Haskell/doc/index.html
cabal: Error: some packages failed to install:
GLFW-0.4.2 failed during the building phase. The exception was:
ExitFailure 1
HipmunkPlayground-5.2.0.3 depends on GLFW-0.4.2 which failed to install.
$ cabal install glfw
(dozens of GLFW warnings)
...
cabal: Error: some packages failed to install:
GLFW-0.4.2 failed during the building phase. The exception was:
ExitFailure 1

Cheers,

Andrew Pennebaker
www.yellosoft.us

On Tue, Apr 26, 2011 at 4:49 AM, Jason Dagit dag...@gmail.com wrote:



 On Tue, Apr 26, 2011 at 1:38 AM, Andrew Pennebaker 
 andrew.penneba...@gmail.com wrote:

 $ system_profiler SPSoftwareDataType | grep System Version
   System Version: Mac OS X 10.6.7 (10J869)
 $ ghc --version
 The Glorious Glasgow Haskell Compilation System, version 7.0.2
 $ cabal --version
 cabal-install version 0.10.2
 using version 1.10.1.0 of the Cabal library
 $ cabal install hipmunkplayground
 ...
 Updating documentation index /Users/andrew/Library/Haskell/doc/index.html
 cabal: Error: some packages failed to install:
 GLFW-0.4.2 failed during the building phase. The exception was:
 ExitFailure 1
 HipmunkPlayground-5.2.0.3 depends on GLFW-0.4.2 which failed to install.


 GLFW is the package that failed to install.  The reason for that should be
 in the scroll back somewhere but it can often be hard to find when it's
 buried in a huge list of compilation messages.  If you try with just GLFW,
 eg., cabal install GLFW, then it should be easier to spot the error.

 Since you're on a mac, I would highly recommend getting the latest haskell
 platform.  You're on 7.0.2 which has bug fixes that are relevant to build
 failures on OSX, as I understand it.

 Jason

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


[Haskell-cafe] Can't install haskellnet with ghc7

2011-04-26 Thread Charles-Pierre Astolfi
Hi -cafe,

Did anybody managed to install haskellnet from hackage with ghc7?
I tried on windows and mac and I get the following type error:

[ 4 of 11] Compiling Network.HaskellNet.SMTP (
Network/HaskellNet/SMTP.hs, dist/build/Network/HaskellNet/SMTP.o )
Network/HaskellNet/SMTP.hs:269:25:
Couldn't match expected type `Data.Text.Internal.Text'
with actual type `[Char]'
Expected type: Data.Text.Internal.Text
  Actual type: String
In the first argument of `simpleMail', namely `to'
In a stmt of a 'do' expression:
myMail - simpleMail to from subject plainBody htmlBody attachments

Am I missing something?
--
Cp

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


[Haskell-cafe] Good reads?

2011-04-26 Thread Christopher Svanefalk
[I originally posted this over in haskell-beginners. However, since this
list has a lot more traffic, and I am not sure how many people read both
lists, I thought I would post here as well. I apologize for the
doublepost! Just want to make sure I can get some replies from the great
people here who might not read the beginners list]

Hey all,

I have mostly been brought in imperative/OOP languages. In connection
with my college studies, however, I have taken great interest in the
functional paradigm, and would very much like to dig deeper into it.

I am currently reading through Peyton-Jones Haskell: The Craft of
Functional Programming (2nd ed.), as well as a great paper published by
one of my professors
(http://www.cse.chalmers.se/~rjmh/Papers/whyfp.html). However, what
other works, in your opinions, should I look into to get a more complete
understanding of functional programming?

Thanks in advance!

Chris



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


[Haskell-cafe] Creating polygons in qtHaskell

2011-04-26 Thread Øystein Kolsrud
Hi! I'm using qtHaskell and I'm trying to create a
QGraphicsPolygonItem object. From what I see I need to create a
QPolygonF item that I can supply to the constructor, but to populate
the QPolygonF I need to use methods of the QVector class that
QPolygonF inherits and I can't figure out how to do that. It seems
that QVector is not part of the qtHaskell library. What I would like
to do is something like this (where mypoints is a list of QPointF):

makePolygon = do
  polygon - qPolygonF ()
  mapM (pushBack polygon) mypoints
  qGraphicsPolygonItem_nf polygon

However, pushBack doesn't seem to be available. Does anyone know a way
to do this?

-- 
Mvh Øystein Kolsrud

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


Re: [Haskell-cafe] Can't install haskellnet with ghc7

2011-04-26 Thread Vincent Hanquez

 On 04/26/2011 10:17 PM, Charles-Pierre Astolfi wrote:

Hi -cafe,

Did anybody managed to install haskellnet from hackage with ghc7?
I tried on windows and mac and I get the following type error:

[ 4 of 11] Compiling Network.HaskellNet.SMTP (
Network/HaskellNet/SMTP.hs, dist/build/Network/HaskellNet/SMTP.o )
Network/HaskellNet/SMTP.hs:269:25:
 Couldn't match expected type `Data.Text.Internal.Text'
 with actual type `[Char]'
 Expected type: Data.Text.Internal.Text
   Actual type: String
 In the first argument of `simpleMail', namely `to'
 In a stmt of a 'do' expression:
 myMail- simpleMail to from subject plainBody htmlBody attachments

Am I missing something?


your mime-mail library is too recent.
the upper version in the cabal file of haskellnet is not limited, so 
it's picking up the 0.3.0 version which is incompatible with the 0.2.x.


Otherwise it was working for me with the previous version for both ghc6 
and ghc7.


--
Vincent

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


Re: [Haskell-cafe] Good reads?

2011-04-26 Thread Edward Amsden
On Tue, Apr 26, 2011 at 5:48 PM, Christopher Svanefalk
christopher.svanef...@gmail.com wrote:
 I am currently reading through Peyton-Jones Haskell: The Craft of
 Functional Programming (2nd ed.), as well as a great paper published by
 one of my professors
 (http://www.cse.chalmers.se/~rjmh/Papers/whyfp.html). However, what
 other works, in your opinions, should I look into to get a more complete
 understanding of functional programming?

You might consult the Typeclassopedia (Brent Yorgey).

Understanding these typeclasses helped me start understand the power
of abstraction that Haskell (and FP in general) gives a programmer.

quoth the abstract:
The standard Haskell libraries feature a number of type classes with
algebraic or category-theoretic underpinnings. Becoming a fluent
Haskell hacker requires intimate familiarity with them all, yet
acquiring this familiarity often involves combing through a mountain
of tutorials, blog posts, mailing list archives, and IRC logs.

The goal of this article is to serve as a starting point for the
student of Haskell wishing to gain a firm grasp of its standard type
classes. The essentials of each type class are introduced, with
examples, commentary, and extensive references for further reading.

http://www.haskell.org/wikiupload/8/85/TMR-Issue13.pdf, page 13

And from a fellow student: have fun!

-- 
Edward Amsden
Student
Computer Science
Rochester Institute of Technology
www.edwardamsden.com

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


Re: [Haskell-cafe] ANN: Leksah 0.10.0

2011-04-26 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 4/26/11 09:15 , Daniel Fischer wrote:
 On Tuesday 26 April 2011 02:00:32, jutaro wrote:
 Well, it is a bit more intricate to invert the sides. After
 * swapping LeftP and RightP in Edit Prefs - Initial Pane positions
 * Close all panes and pane groups. (You may leave an editor window open,
 so that you better see what happens in the next steps).
 * Collapse all (Hit Ctrl-1 - 2 times)
 * Split vertical (Hit Ctrl-2), put the focus to the left, split
 horizontal (Hit Ctrl-3)
 * Go to Panes Menu and reopen the Log and the Browser and an editor
 Window * Configure tabs as you like
 * Save the session or restart Leksah
 
 Intricate indeed. If some day you have too much time, consider adding 
 configuration options for that. Until then, how about putting that in the 
 docs?

How about a layout editor mode where you can drag panes around,
double-click somewhere to split at that point (hold shift for horizontal
split, maybe?), and a window palette to drag windows into panes?

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

iEYEARECAAYFAk23VXoACgkQIn7hlCsL25X/0gCgpKLaNqOeHbgO8D4ZQ38y1EQV
ZisAnik6XZHVPGs3k50xGZ+MEJCaAfZC
=P0vf
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] Good reads?

2011-04-26 Thread Eric Rasmussen
I'm currently reading Real World Haskell (
http://book.realworldhaskell.org/read/), and it's an excellent book. It goes
into detail on quite a few interesting and practical uses of the language.

Also, in the spirit of this discussion, is there a resource that attempts to
compare libraries for common tasks so developers can make informed decisions
without having to research each library or approach on their own? As an
example, in other languages you might read about CSV parsing from a few
different sources and see a general consensus on how to approach it. After
hours of digging through code on Hackage and reading up on different
approaches, I can't seem to find a consensus in Haskell.

If anyone knows of a book/resource that breaks down different approaches to
common problems and when/why you might choose one over the other, I'm very
interested.

-Eric Rasmussen


On Tue, Apr 26, 2011 at 3:52 PM, Edward Amsden eca7...@cs.rit.edu wrote:

 On Tue, Apr 26, 2011 at 5:48 PM, Christopher Svanefalk
 christopher.svanef...@gmail.com wrote:
  I am currently reading through Peyton-Jones Haskell: The Craft of
  Functional Programming (2nd ed.), as well as a great paper published by
  one of my professors
  (http://www.cse.chalmers.se/~rjmh/Papers/whyfp.html). However, what
  other works, in your opinions, should I look into to get a more complete
  understanding of functional programming?

 You might consult the Typeclassopedia (Brent Yorgey).

 Understanding these typeclasses helped me start understand the power
 of abstraction that Haskell (and FP in general) gives a programmer.

 quoth the abstract:
 The standard Haskell libraries feature a number of type classes with
 algebraic or category-theoretic underpinnings. Becoming a fluent
 Haskell hacker requires intimate familiarity with them all, yet
 acquiring this familiarity often involves combing through a mountain
 of tutorials, blog posts, mailing list archives, and IRC logs.

 The goal of this article is to serve as a starting point for the
 student of Haskell wishing to gain a firm grasp of its standard type
 classes. The essentials of each type class are introduced, with
 examples, commentary, and extensive references for further reading.

 http://www.haskell.org/wikiupload/8/85/TMR-Issue13.pdf, page 13

 And from a fellow student: have fun!

 --
 Edward Amsden
 Student
 Computer Science
 Rochester Institute of Technology
 www.edwardamsden.com

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

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


Re: [Haskell-cafe] How to keep cabal and ghci package versions in sync?

2011-04-26 Thread Peter Gammie
On 27/04/2011, at 3:04 AM, Rogan Creswick wrote:

 At the moment, cabal-dev ghci just uses the -package-conf and
 -no-user-package-conf flags to restrict ghci to the sandboxed and
 global package dbs.
 
 It's difficult to do more without parsing the content of the project's
 cabal file, and that parser isn't exposed through a library api (it's
 in cabal-install), which makes it a little difficult to use.

Can't you use cabal as a library to do this?

I had a crack at figuring out a ghci command line in TBC (testing by 
convention):

https://github.com/peteg/TBC

while waiting for this cabal feature to be implemented:

http://hackage.haskell.org/trac/hackage/ticket/382

Apparently there's a GSoC project that will nail this.

You can fire up TBC with the verbose flag and it will give you a very long ghc 
invocation line that is strongly similar to what cabal uses to compile your 
project. It doubtlessly is incomplete, and probably bit rotten. I will try to 
make it work with the latest Haskell Platform release in the coming weeks.

I welcome patches, but you're better off fixing cabal itself.

cheers
peter

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


Re: [Haskell-cafe] plugins and cabal build

2011-04-26 Thread Michael Snoyman
On Tue, Apr 26, 2011 at 4:56 PM, Andy Stewart lazycat.mana...@gmail.com wrote:
 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com writes:

 On 26 April 2011 04:57, Michael Snoyman mich...@snoyman.com wrote:
 Hi all,

 I'm experimenting with using the plugins package for yesod devel
 server. The basic approach is to use cabal for building the object
 files, and then load them with plugins. I can get everything to work
 when I compile with ghc --make, but I believe name mangling is
 getting in the way with the cabal build route. Can someone give some
 guidance on how to properly mangle the function names so that plugins
 can load them?

 I'm not sure if he reads this list, but Andy Stewart might know (and
 I've CC'd him to this).
 Hi Ivan, sorry for late, too busy on Linux job.

 Yes, i have got hot-swap code work for Manatee
 (http://hackage.haskell.org/package/manatee)

 I used to use plugins, but i found it's buggy.
 So i use GHC-API wrote my own code at:
 https://patch-tag.com/r/AndyStewart/manatee-core/snapshot/current/content/pretty/Manatee/Core/Dynload.hs

 Michael, from your need, you just need read function `dynload`, other
 functions is write for Manatee framework.

 Let me explain function `dynload`:

    dynload :: (String, String, [(String, HValue - IO ())]) - IO ()
    dynload (filepath, moduleName, loadList) = ...

 First argument is FilePath that contain module.
 Second argument is moduleName you need scan.
 Third argument is tuple list that contain symbol you need load and
 callback function for symbol's HValue.

 Once function `dynload` find symbol in target module, it will use below code
 dynamic load new value:

    (do
        hValue - compileExpr (moduleName ++ . ++ symbolName)
        liftIO $ loadFun hValue)

 function `compileExpr` will get the HValue of symbol, then use loadFun
 update HVaule in running program.

 The key is `HValue - IO ()`, you need build TVar/IORef in your
 running program, once you got new HValue, you should write
 writeTVar/writeIORef in function `HValue - IO ()` to update the value of
 TVar/IORef, then you can dynamic loading new value and don't need
 reboot.

 I have draw some picture to explain above framework:
 http://www.flickr.com/photos/48809572@N02/5304662424/in/photostream/lightbox/

 Michael, hope above will help you, good luck! :)

  -- Andy


Hi Andy,

Thanks you for your very helpful reply. I still have your previous
advice on this subject in my things to study list. Looks like taking
the easy way out didn't work after all. Thanks for the great example
to work from, hopefully it will work out properly.

Michael

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