Re: [Haskell-cafe] Poll plea: State of GUI graphics libraries in Haskell

2013-09-26 Thread KC
What does the following mean?

About three years ago, I built a modern replacement of my old Pan and
Vertigo systems (optimized high-level functional graphics in 2D and 3D),
generating screamingly fast GPU rendering code. I'd love to share it with
the community, but I'm unable to use it even myself.


Casey


On Thu, Sep 26, 2013 at 8:32 PM, Conal Elliott co...@conal.net wrote:

 I'm polling to see whether there are will and expertise to reboot graphics
 and GUIs work in Haskell. I miss working on functional graphics and GUIs in
 Haskell, as I've been blocked for several years (eight?) due to the absence
 of low-level foundation libraries having the following properties:

 * cross-platform,
 * easily buildable,
 * GHCi-friendly, and
 * OpenGL-compatible.

 The last several times I tried Gtk2hs, I was unable to compile it on my
 Mac. Years ago when I was able to compile, the GUIs looked and interacted
 like a Linux app, which made them awkward and upleasant to use. wxHaskell
 (whose API and visual appearance I prefered) has for years been
 incompatible with GHCi, in that the second time I open a top-level window,
 the host process (GHCi) dies abruptly. Since my GUI  graphics programs are
 often one-liners, and I tend to experiment a lot, using a full compilation
 greatly thwarts my flow. For many years, I've thought that the situation
 would eventually improve, since I'm far from the only person who wants GUIs
 or graphics from Haskell.

 About three years ago, I built a modern replacement of my old Pan and
 Vertigo systems (optimized high-level functional graphics in 2D and 3D),
 generating screamingly fast GPU rendering code. I'd love to share it with
 the community, but I'm unable to use it even myself.

 Two questions:

 * Am I mistaken about the current status? I.e., is there a solution for
 Haskell GUI  graphics programming that satisfies the properties I'm
 looking for (cross-platform, easily buildable, GHCi-friendly, and
 OpenGL-compatible)?
 * Are there people willing and able to fix this situation? My own
 contributions would be to test and to share high-level composable and
 efficient GUI and graphics libraries on top of a working foundation.

 Looking forward to replies. Thanks,

 -- Conal

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




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


Re: [Haskell-cafe] Alternative name for return

2013-08-05 Thread KC
I thought a pure value was being returned from the monad. :)


On Mon, Aug 5, 2013 at 10:32 PM, Christian Sternagel
c.sterna...@gmail.comwrote:

 Dear Jurriën.

 personally, I like lift (which is of course already occupied in
 Haskell), since an arbitrary value is lifted into a monad. (The
 literature sometimes uses unit.)

 cheers

 chris


 On 08/06/2013 02:14 PM, J. Stutterheim wrote:

 Dear Cafe,


 Suppose we now have the opportunity to change the name of the `return`
 function in Monad, what would be a better  name for it? (for some
 definition of better)

 N.B. I am _not_ proposing that we actually change the name of `return`. I
 do currently have the opportunity to pick names for common functions in a
 non-Haskell related project, so I was wondering if there perhaps is a
 better name for `return`.


 - Jurriën
 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe



 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe




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


Re: [Haskell-cafe] memoization

2013-07-22 Thread KC
Have you tried the compiler?


On Sun, Jul 21, 2013 at 11:59 PM, Christopher Howard 
christopher.how...@frigidcode.com wrote:

  When I previously asked about memoization, I got the impression that
 memoization is not something that just happens magically in Haskell. Yet,
 on a Haskell wiki page about 
 Memoizationhttp://www.haskell.org/haskellwiki/Memoization#Memoization_with_recursion,
 an example given is

  memoized_fib :: Int - Integer
 memoized_fib = (map fib [0 ..] !!)
where fib 0 = 0
  fib 1 = 1
  fib n = memoized_fib (n-2) + memoized_fib (n-1)


 I guess this works because, for example, I tried memoized_fib 1 and
 the interpreter took three or four seconds to calculate. But every
 subsequent call to memoized_fib 1 returns instantaneously (as does
 memoized_fib 10001).

 Could someone explain the technical details of why this works? Why is map
 fib [0 ..] not recalculated every time I call memoized_fib?

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




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


[Haskell-cafe] There was someone here going to use REPA and a functional way to find eigenvalues :)

2013-07-11 Thread KC
Have you succeeded?

In general, is there a functional way to do matrix manipulations?
Linear algebra?
Linear programming?
Integer Programming?
Numerical Analysis?

Casey

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


[Haskell-cafe] Do combinatorial algorithms have a matroid strucutre XOR non-matroid structure?

2013-07-11 Thread KC
I ask this on this mailing list because there are quite a few
mathematically oriented people here.

Casey

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


Re: [Haskell-cafe] Is the following implemented by a sparse matrix representation? type Graph n w = Array (n, n) (Maybe w)

2013-07-10 Thread KC
Thank you :)


On Wed, Jul 10, 2013 at 8:33 AM, Twan van Laarhoven twa...@gmail.comwrote:

 The standard array types, such as Array (n,n) (Maybe w) will be
 implemented as a dense array. If you want to use a sparse matrix, you will
 explicitly have to ask for it. For instance by using something like IntMap
 (IntMap w) or Map (n,n) w or Array n (IntMap w). Each of these
 representations is slightly different, and there will be different
 trade-offs.


 Twan

 On 09/07/13 23:26, KC wrote:
  Is the following implemented by a sparse matrix representation?

  type Graph n w = Array (n,n) (Maybe w)

 --
 --
 Regards,
 KC




 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe




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


[Haskell-cafe] Is the following implemented by a sparse matrix representation? type Graph n w = Array (n, n) (Maybe w)

2013-07-09 Thread KC
type Graph n w = Array (n,n) (Maybe w)

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


[Haskell-cafe] Will Haskell Platform 2012.4.0.0 uninstall cleanly for the installation of 2013.2.0.0

2013-04-11 Thread KC
:)

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


Re: [Haskell-cafe] Mobile app development?

2013-01-19 Thread KC
You would need native compilers for all the platforms and/or virtual
machine technology.

Might be easier to have the browser connect to a Haskell app.


On Sat, Jan 19, 2013 at 10:42 AM, Andrew Pennebaker
andrew.penneba...@gmail.com wrote:
 There are currently very few options, especially free and open source
 options, when it comes to developing cross-platform mobile applications.
 It's basically web apps with JavaScript, or C++. If Haskell supported app
 development on Android, iOS, and Windows RT, that alone would bring in more
 developers.

 Similarly, there are very few languages for mobile development that take
 advantage of multiple cores and multiple CPUs. Haskell's `parmap` is an
 amazing selling point. Can we please prioritize mobile support? I'd much
 rather write everything in ML than PhoneGap.

 --
 Cheers,

 Andrew Pennebaker
 www.yellosoft.us

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




-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Mobile app development?

2013-01-19 Thread KC
Then it looks as if the easier implementation would be small Haskell
VM's for the various platforms with a byte code compiler.
I do not believe the JVM supports all the optimizations GHC can do.

Oh wait!
Can the LLVM be easily ported to do this?


On Sat, Jan 19, 2013 at 11:40 AM, Andrew Pennebaker
andrew.penneba...@gmail.com wrote:

 Might be easier to have the browser connect to a Haskell app.


 Not all apps can be run as thin clients. 3D video games and other intensive
 programs aren't easily done as thin clients. Mobile Haskell would be very
 powerful, because concurrency and parallelism aren't something the C-family
 languages are supporting that well.




 On Sat, Jan 19, 2013 at 10:42 AM, Andrew Pennebaker
 andrew.penneba...@gmail.com wrote:
  There are currently very few options, especially free and open source
  options, when it comes to developing cross-platform mobile applications.
  It's basically web apps with JavaScript, or C++. If Haskell supported
  app
  development on Android, iOS, and Windows RT, that alone would bring in
  more
  developers.
 
  Similarly, there are very few languages for mobile development that take
  advantage of multiple cores and multiple CPUs. Haskell's `parmap` is an
  amazing selling point. Can we please prioritize mobile support? I'd much
  rather write everything in ML than PhoneGap.
 
  --
  Cheers,
 
  Andrew Pennebaker
  www.yellosoft.us
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 



 --
 --
 Regards,
 KC




 --
 Cheers,

 Andrew Pennebaker
 www.yellosoft.us



-- 
--
Regards,
KC

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


[Haskell-cafe] Is http://hackage.haskell.org/packages/hackage.html having a challenging serving up archive.tar?

2013-01-09 Thread KC
:)

-- 
--
Regards,
KC

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


[Haskell-cafe] Are there REPA linear algebra routines? e.g. Eigenvalues?

2012-12-05 Thread KC
:)

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Why is boxed mutable array so slow?

2012-12-01 Thread KC
Boxed arrays have a wrapper (extra layer of indirection) to allow for
a fully evaluated value, an unevaluated thunk, or the special value
bottom (a value that can contain bottom is referred to as lifted).

Unboxed arrays always have some value; that is, they cannot represent
a thunk nor bottom.


On Sat, Dec 1, 2012 at 8:09 AM, Branimir Maksimovic bm...@hotmail.com wrote:
 I have made benchmark test inspired by
 http://lemire.me/blog/archives/2012/07/23/is-cc-worth-it/

 What surprised me is that unboxed array is much faster than boxed array.
 Actually boxed array performance is on par with standard Haskell list
 which is very slow.
 All in all even unboxed array is about 10 times slower than Java version.
 I don't understand why is even unboxed array so slow.
 But! unboxed array consumes least amount of RAM.
 (warning, program consumes more than 3gb of ram)

  bmaxa@maxa:~/examples$ time ./Cumul
 boxed array
 last 262486571 seconds 4.972
 unboxed array
 last 262486571 seconds 0.776
 list
 last 262486571 seconds 6.812

 real0m13.086s
 user0m11.996s
 sys 0m1.080s

 -
 {-# LANGUAGE CPP, BangPatterns #-}
 import System.CPUTime
 import Text.Printf
 import Data.Array.IO
 import Data.Array.Base
 import Data.Int
 import Control.DeepSeq
 import System.Mem

 main :: IO()
 main = do
 (newArray_ (0,n'-1) :: IO(A)) = test boxed array
 performGC
 (newArray_ (0,n'-1) :: IO(B)) = test unboxed array
 performGC
 begin - getCPUTime
 printf list\nlast %d $ last $ force $ take n' $ sum' data'
 end - getCPUTime
 let diff = (fromIntegral (end - begin)) / (10^12)
 printf  seconds %.3f\n (diff::Double)

 test s a = do
 putStrLn s
 begin - getCPUTime
 init' a
 partial_sum a
 end - getCPUTime
 let diff = (fromIntegral (end - begin)) / (10^12)
 last - readArray a (n'-1)
 printf last %d seconds %.3f\n last (diff::Double)

 n' :: Int
 n' = 50 * 1000 * 1000

 type A = IOArray Int Int32
 type B = IOUArray Int Int32

 init' a = do
 (_,n) - getBounds a
 init a 0 n
 where
 init a k n
 | k  n = return ()
 | otherwise = do
 let  !x = fromIntegral $ k + k `div` 3
 unsafeWrite a k x
 init a (k+1) n

 partial_sum a = do
 (_,n) - getBounds a
 k - unsafeRead a 0
 ps a 1 n k
 where
 ps a i n s
 | i  n = return ()
 | otherwise = do
 k - unsafeRead a i
 let !l = fromIntegral $ s + k
 unsafeWrite a i l
 ps a (i+1) n l

 data' :: [Int32]
 data' = [k + k `div` 3 | k - [0..] ]

 sum' = scanl1 (+)


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




-- 
--
Regards,
KC

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


Re: [Haskell-cafe] How to incrementally update list

2012-11-30 Thread KC
Why do you want to incrementally update this list a lot of times?

The question would affect the answer you get; i.e. some context
(non-monadically speaking). :D


On Wed, Nov 28, 2012 at 3:43 AM, Branimir Maksimovic bm...@hotmail.com wrote:
 Problem is following short program:
 list = [1,2,3,4,5]

 advance l = map (\x - x+1) l

 run 0 s = s
 run n s = run (n-1) $ advance s

 main = do
 let s =  run 5000 list
 putStrLn $ show s

 I want to incrementally update list lot of times, but don't know
 how to do this.
 Since Haskell does not have loops I have to use recursion,
 but problem is that recursive calls keep previous/state parameter
 leading to excessive stack.and memory usage.
 I don't know how to tell Haskell not to keep previous
 state rather to release so memory consumption becomes
 managable.

 Is there some solution to this problem as I think it is rather
 common?


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




-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Compilers: Why do we need a core language?

2012-11-22 Thread KC
I believe the question you are asking is why do large software systems
need to be designed in terms of levels or some other software
engineering construct(s).

To manage their complexity as opposed to getting mangled in their complexity. :D


-- 
--
Regards,
KC

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


[Haskell-cafe] To cabal install cabal-install on Windows ...

2012-11-22 Thread KC
- completely remove the earlier Haskell Platform
- reboot
- defragment the partition/hard drive
- reboot
- install the newer Haskell Platform
- reboot
- defragment the partition/hard drive (recommended)
- reboot
- cabal update
- cabal install cabal-install

It seems like what is slowing down the install process (or hanging it)
is the thrashing of your hard drive to find all the little file
fragments it needs during the install

Casey

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] code length in Haskell, a comparison

2012-11-19 Thread KC
I am leery of code comparisons (but not Timothy Leary of them).

Clojure being a JVM language has the advantage of the massive Java
class libraries.

If Haskell could tie in fairly seamlessly to the Java class libraries ...

If more developers learned the need for finer grained abstraction ...



On Mon, Nov 19, 2012 at 7:55 PM, Gregory Guthrie guth...@mum.edu wrote:
 There is some interesting data in the article at:

Code Length Measured in 14 Languages
 http://blog.wolfram.com/2012/11/14/code-length-measured-in-14-languages/

 basically comparing program lengths in various languages, and some ensuing 
 discussion of how this relates to language expressiveness, etc.
 (He does all of his analysis in Mathematica, which is the goal of the 
 article.)

 It is interesting to see how well Haskell showed in the data; and it would 
 also be interesting to see how well it could replicate the analysis example 
 which was a nice example of web data scraping!

 The data is the length of a series of programs written in a number of 
 languages (data from: http://rosettacode.org/wiki/Rosetta_Code).
 (The columns don't map well to text only, Haskell column marked with  
 (Why doesn't this list support HTML?)).
   See nicer version at: http://pastehtml.com/view/ciy7woohv.rtxt

 The average for Haskell of 1.89 means that on the average the same program in 
 Haskell takes ~2x in the other languages.
 Given the correlation of size to clarity, complexity, effort, and errors, 
 this is a good thing! :-)


Massive Snip!


 Overall Ranking:
Clojure  0.41
Haskell  0.83
R0.85
MATLAB   1.14
JavaScript   1.27
Ruby 1.36
Common Lisp  1.56
Python   1.61
C++  1.68
C#   1.85
Pascal   1.86
Fortran  2.33
C++  2.58
C4.09
 ---

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



-- 
--
Regards,
KC

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


[Haskell-cafe] Instead of Haskell running on the JVM is there a way for Haskell to call a JVM language ...

2012-11-19 Thread KC
Instead of Haskell running on the JVM is there a way for Haskell to
call a JVM language (or generate bytecode) to access the Java class
libraries when needed?

Or

Is there a way for a JVM language or bytecode to call Haskell when needed?

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-10-13 Thread KC
The latest Haskell Platform is 2012.2.0.0

You are apparently running a much older version.

 #!c:/Program Files/Haskell Platform/2010.2.0.0/bin/ runhaskell



-- 
--
Regards,
KC

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


[Haskell-cafe] What is a functional approach to linear algebra routines? I see REPA warns that one must use fusion or risk slow routines.

2012-10-04 Thread KC
Apparently using STUarrays in an imperative fashion is fraught with
peril (and the performance of molasses).

Casey

-- 
--
Regards,
KC

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


[Haskell-cafe] One of the new buzz phrases is Event-Sourcing; is Haskell suitable for this?

2012-09-29 Thread KC
http://martinfowler.com/eaaDev/EventSourcing.html

http://martinfowler.com/articles/lmax.html


-- 
--
Regards,
KC

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


[Haskell-cafe] If I want to make a pure Haskell eigenvalue, etc. package without calling to LAPACK, etc ...

2012-09-29 Thread KC
What are some good basis (pun intended) to start from?
e.g. REPA?
or ?

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Monads

2012-09-29 Thread KC
From:

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


The computation doesn't have to be impure and can be pure itself as
well. Then monads serve to provide the benefits of separation of
concerns, and automatic creation of a computational pipeline.


On Sat, Sep 29, 2012 at 6:57 PM, Vasili I. Galchin vigalc...@gmail.com wrote:
 Hello,

 I would an examples of monads that are pure, i.e. no side-effects.

 Thank you,

 Vasili


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




-- 
--
Regards,
KC

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


[Haskell-cafe] Haskell seems setup for iterative numerics; i.e. a standard example is Newton's method where lazy evaluation ...

2012-09-05 Thread KC
separates control from computation.

It seems as if Haskell would be better for iterative matrix methods
rather than direct calculation.

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Haskell seems setup for iterative numerics; i.e. a standard example is Newton's method where lazy evaluation ...

2012-09-05 Thread KC
The REPA package/library doesn't have LU factorization, eigenvalues, etc.


On Wed, Sep 5, 2012 at 12:59 PM, Carter Schonwald
carter.schonw...@gmail.com wrote:
 Hello KC,
 you should check out the Repa library then and see how it works for you.
 Cheers
 -Carter

 On Wed, Sep 5, 2012 at 12:46 PM, KC kc1...@gmail.com wrote:

 separates control from computation.

 It seems as if Haskell would be better for iterative matrix methods
 rather than direct calculation.

 --
 --
 Regards,
 KC

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





-- 
--
Regards,
KC

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


Re: [Haskell-cafe] hstats median algorithm

2012-09-02 Thread KC
Is there any special structure in your data that could be exploited?



On Sat, Sep 1, 2012 at 6:17 PM, Gershom Bazerman gersh...@gmail.com wrote:
 In my experience, doing much better than the naive algorithm for median is
 surprisingly hard, and involves a choice from a range of trade-offs. Did you
 have a particular better algorithm in mind?

 If you did, you could write it, and contact the package author with a patch.

 You also may be able to find something of use in Edward Kmett's
 order-statistics package:
 http://hackage.haskell.org/package/order-statistics

 Cheers,
 Gershom


 On 9/1/12 3:26 PM, David Feuer wrote:

 The median function in the hstats package uses a naive O(n log n)
 algorithm. Is there another package providing an O(n) option? If not,
 what would it take to get the package upgraded?



-- 
--
Regards,
KC

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


[Haskell-cafe] Is it worth adding Gaussian elimination and eigenvalues to REPA?

2012-08-31 Thread KC
I realize if one wants speed you probably want to use the hMatrix
interface to GSL, BLAS and LAPACK.

Worth it in the sense of have a purely functional implementation.

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Does someone have a compiled binary of the LLVM for Windows 7 or must one compile the source?

2012-08-18 Thread KC
Thank you

It involves going to

- 
path\cabal\packages\hackage.haskell.org\repa-algorithms\3.2.1.1\repa-algorithms-3.2.1.1

- making the cabal file changes

- re-tar-ing

- re-gzip-ing


On Wed, Aug 15, 2012 at 6:29 PM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 On 16 August 2012 11:21, KC kc1...@gmail.com wrote:
 I just want to get started on some matrix operations with REPA.

 Or is there a library (package?) like REPA without using the LLVM?

 If you're referring to your recent problems with repa-algorithms, you
 can try this:

 cabal unpack repa-algorithms
 # Not sure of the syntax for changing directories in the cmd.exe terminal
 cd repa-algorithms-version
 # Use a text editor to remove the line -fllvm from the .cabal file
 cabal install


 --
 --
 Regards,
 KC

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



-- 
--
Regards,
KC

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


[Haskell-cafe] Does someone have a compiled binary of the LLVM for Windows 7 or must one compile the source?

2012-08-15 Thread KC
I just want to get started on some matrix operations with REPA.

Or is there a library (package?) like REPA without using the LLVM?

-- 
--
Regards,
KC

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


[Haskell-cafe] For consistency; it would be better if the import statement matched the cabal install statement or :m form.

2012-08-14 Thread KC
:m +Data.Array.Repa.Algorithms.Randomish

cabal install repa.algrothms

would be more consistent.

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] I use cabal install repa but then WinGHCi says module Data.Array.Rep.Algorithms.Ramdomish not found.

2012-08-13 Thread KC
The install of repa-algorithms fails saying it can't cannot find an llvm.


In any case why can't the install syntax be
cabal install repa.algorithms
then it would be more consistent with the import statement.


On Sun, Aug 12, 2012 at 4:00 PM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 I think you need to install repa-algorithms.

 On 13 August 2012 04:18, KC kc1...@gmail.com wrote:
 --
 --
 Regards,
 KC

 ___
 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



-- 
--
Regards,
KC

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


[Haskell-cafe] I use cabal install repa but then WinGHCi says module Data.Array.Rep.Algorithms.Ramdomish not found.

2012-08-12 Thread KC
-- 
--
Regards,
KC

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


Re: [Haskell-cafe] [Haskell-beginners] vector indexing time

2012-08-03 Thread KC
Thank you for that insight.  :)

On Fri, Aug 3, 2012 at 4:50 AM, Heinrich Apfelmus apfel...@quantentunnel.de
 wrote:


 Creating the vector still takes time proportional to the length of the
 vector. In fact, it appears that in your example, the  vector  packages
 optimizes the creation time to create only up to the element that you
 actually demand.

 The linear time you're seeing is not the result of an inefficiency of
 vector indexing, but the result of an efficiency in vector creation.


 Best regards,
 Heinrich Apfelmus

 --
 http://apfelmus.nfshost.com


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


[Haskell-cafe] Why is the the transpose function in Data.List more complicated?

2012-08-03 Thread KC
Transpose in Data.List is the following:

transpose   :: [[a]] - [[a]]
transpose [] = []
transpose ([]   : xss)   = transpose xss
transpose ((x:xs) : xss) = (x : [h | (h:_) - xss]) : transpose (xs :
[ t | (_:t) - xss])


Yet this seems to work.

transp :: [[b]] - [[b]]
transp ([]:_)   = []
transp rows = map head rows : transp (map tail rows)


Why is the the transpose function in Data.List more complicated?

--
--
Regards,
KC

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


[Haskell-cafe] The following is supposed to be initializing a 2D array but it doesn't seem to work.

2012-07-31 Thread KC
newArr :: (Ix i) = i - i - e - Array i e
newArr n m x = listArray (n,m) (repeat
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:repeat
x)

-

Prelude http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html
Data.Array newArr 0 10 0
array (0,10) 
[(0,0),(1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0),(9,0),(10,0)]

Prelude http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html
Data.Array newArr (0,0) (5,5) 0
array ((0,0),(5,5))
[((0,0),0),((0,1),0),((0,2),0),((0,3),0),((0,4),0),((0,5),0),((1,0),0),((1,1),0),((1,2),0),((1,3),0),((1,4),0),((1,5),0),((2,0),0),((2,1),0),((2,2),0),((2,3),0),((2,4),0),((2,5),0),((3,0),0),((3,1),0),((3,2),0),((3,3),0),((3,4),0),((3,5),0),((4,0),0),((4,1),0),((4,2),0),((4,3),0),((4,4),0),((4,5),0),((5,0),0),((5,1),0),((5,2),0),((5,3),0),((5,4),0),((5,5),0)]


All I am getting is this:
array ((1,5),(1,5)) [((1,5),1.0)]

Maybe the behaviour of ghc was changed since the article was written.


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


Re: [Haskell-cafe] The following is supposed to be initializing a 2D array but it doesn't seem to work.

2012-07-31 Thread KC
That was it!

On Tue, Jul 31, 2012 at 3:34 PM, Jan-Willem Maessen
jmaes...@alum.mit.eduwrote:



 On Tue, Jul 31, 2012 at 5:52 PM, KC kc1...@gmail.com wrote:

 All I am getting is this:

 array ((1,5),(1,5)) [((1,5),1.0)]

 Maybe the behaviour of ghc was changed since the article was written.


 I think you've made a common mistake here.  Array bounds are (lower in all
 dimensions, upper in all dimensions).  So perhaps you intended to use the
 bounds ((1,1), (5,5)) in your code?

 I make this mistake frequently.

 -Jan-Willem Maessen




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


[Haskell-cafe] I can see lists working for matrix algorithms if the access patterns are mostly from the start or end of rows and columns.

2012-07-15 Thread KC
Are there any such matrix algorithms that operate mainly from the start or
end or rows and columns?

Note: If the access pattern starts from the end of a row then one stores
the row in reverse order in a list.

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


Re: [Haskell-cafe] [Haskell-beginners] Graph Coloring Library?

2012-07-14 Thread KC
On Hackage there is the Graphalyze package but it doesn't seem to do vertex
coloring.

Are you talking about undirected graphs?


On Sat, Jul 14, 2012 at 12:23 PM, Alec Story av...@cornell.edu wrote:

 I'd prefer an exact solution, but it doesn't have to be particularly
 performant (this is research code).

 The graphs are pretty small in general, all my test cases will have  10
 nodes, but have high connectivity.  They don't have any special properties.
 On Jul 14, 2012 2:50 PM, KC kc1...@gmail.com wrote:

 Are you looking for an exact or approximate solution.

 How many nodes and edges?

 Any special properties that the graph has?


 On Fri, Jul 13, 2012 at 1:43 PM, Alec Story av...@cornell.edu wrote:

 I have a problem where I need to find the smallest k-coloring for a
 graph that represents conflicts between objects.  Is there a Haskell
 library that will do this for me?  I'm not particularly concerned about
 speed, and it's unlikely that I'll generate really bad edge cases, but I'd
 prefer to do something other than write the really bad try-every-case
 algorithm.

 --
 Alec Story
 Cornell University
 Biological Sciences, Computer Science 2012

 ___
 Beginners mailing list
 beginn...@haskell.org
 http://www.haskell.org/mailman/listinfo/beginners




 --
 --
 Regards,
 KC




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


Re: [Haskell-cafe] [Haskell-beginners] Graph Coloring Library?

2012-07-14 Thread KC
This may help:
- use hMatrix to find the eigenvalues of the adjacency matrix

Then by the following theorems:

An upper bound on the chromatic number in terms of eigenvalues was
discovered by Wilf(1967).

Chromatic Number(G) = 1 + lambda_1(G)

Hoffman (1977) discovered a lower bound on the chromatic number in terms of
the smallest and largest eigenvalue.

Chromatic Number(G)  = 1 - (lambda_1/lambda_n) for n=2.

From The Mutually Beneficial Relationship of Graphs and Matrices, Richard
A. Brualdi,CBMS Series,Number 115, 2011.



On Fri, Jul 13, 2012 at 1:43 PM, Alec Story av...@cornell.edu wrote:

 I have a problem where I need to find the smallest k-coloring for a graph
 that represents conflicts between objects.  Is there a Haskell library that
 will do this for me?  I'm not particularly concerned about speed, and it's
 unlikely that I'll generate really bad edge cases, but I'd prefer to do
 something other than write the really bad try-every-case algorithm.

 --
 Alec Story
 Cornell University
 Biological Sciences, Computer Science 2012

 ___
 Beginners mailing list
 beginn...@haskell.org
 http://www.haskell.org/mailman/listinfo/beginners




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


[Haskell-cafe] There is some article mentioning that FP is mainly good for mathematical and list programming.

2012-07-10 Thread KC
There is some article mentioning that functional programming is mainly good
for mathematical programming and list programming because otherwise it is
to cryptic for business and database applications.

Being semi-intelligent, I thought I could reduce what others think of as
cryptic but maybe instead of 18 wheels I have only 17 wheels. :D

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


Re: [Haskell-cafe] Best way to build a GHC backend?

2012-07-07 Thread KC
As to your porting of Haskell to the JVM question; the JVM would be unable
to perform all the optimizations that GHC can do.  There is really not much
point in running slow code.

JavaScript is interesting since the JIT compiler gets better all the time.


On Sat, Jul 7, 2012 at 10:02 PM, Jonathan Geddes
geddes.jonat...@gmail.comwrote:

 Venerable Haskell Hackers,

 I love Haskell and think it should run everywhere. Now supposing I would
 like to build another backend for GHC, perhaps for Java Bytecode, .Net CIL,
 or JavaScript, What would be the best way to approach that? I can think of
 a few options:

 1. Produce External Core with -fext-core and compile that with a
 completely separate compiler
 2. Use the GHC apis to build a compiler that reuses a load of GHC's code,
 but has it's own backend
 3. Add a new backend directly into GHC

 Any other options?

 While I'm on the subject, why has Haskell not been ported to the likes of
 the JVM, .NET CLR, or JavaScript? Are Haskell's non-strict semantics just
 too different from the semantics of these other platforms?

 SPJ is known for saying that Haskell's plan for world domination is
 support for many parallelism/concurrency idioms. I believe running on many
 platforms is just as important. From my point of view, languages that
 cannot run on one of the 3 aforementioned platforms will become irrelevant.
 (with the exception of C, of course).

 Thoughts?

 --J Arthur

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




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


[Haskell-cafe] Is there a GHC flag that will allow mutable top level state while you are debugging and then ...

2012-07-05 Thread KC
you can turn the flag off when you are ready to do the computational heavy
lifting so that you don't have to modify your code base?

That is, GHC can then apply its algebraic transformation optimizations to
the code algebra of the pure functions.

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


Re: [Haskell-cafe] [Haskell-beginners] Function application versus function composition performance

2012-06-19 Thread KC
A good functional programming language has a good code algebra after
parsing to which algebraic transformations can be applied for optimization.

For example, reducing the need for generating intermediate data structures.

See: fusion.



On Tue, Jun 19, 2012 at 3:01 PM, Matt Ford m...@dancingfrog.co.uk wrote:

 Hi All,

 My last question got me thinking (always dangerous): an expression
 that doubles a list and takes the 2nd element (index 1), I assume,
 goes through the following steps.

 double (double [1,2,3,4]) !! 1
 double ( 1*2 : double [2,3,4]) !! 1
 1*2*2 : double ( double [2,3,4] ) !! 1
 1*2*2 : double ( 2*2 : double [3,4] ) !! 1
 1*2*2 : 2*2*2 : double ( double [3,4] ) !! 1
 2*2*2
 8

 Up until the element requested all the proceeding elements have to
 have the expression formed as Haskell process the calculation.

 Now, I want to compare this to using function composition

 ( double . double ) [ 1 ,2, 3, 4 ] !! 1

 This is the bit I'm unsure of - what does the composition look like.
 It is easy to see that it could be simplified to something like:

 ( double . double) (x:xs) = x*4 : (double . double) xs

 This would mean the steps could be written

 (double . double) [ 1,2,3,4 ] !! 1
 (1*4 : (double.double) [2,3,4]) !! 1
 (1*4 : 2*4 : (double.double) [ 3,4 ]) !! 1
 2*4
 8

 Ignoring the start and end steps, it will be half the number of steps
 compared to the application version.  Significant then, over long
 lists.

 So is this true, are composite functions simplified in Haskell in
 general so that they may have improved performance over function
 application?

 I've seen posts on the internet that say it's a matter of style only:

 http://stackoverflow.com/questions/3030675/haskell-function-composition-and-function-application-idioms-correct-us
 .
  But my reasoning suggests it could be more than that.

 Perhaps, function application is similarly optimised - maybe by
 replacing all functions applications with composition and then
 simplifying?  Or maybe the simplifying/optimisation step never
 happens?  As you can see I'm just guessing at things :-)  But it's
 nice to wonder.

 Many thanks for any pointers,

 Matt.

 ___
 Beginners mailing list
 beginn...@haskell.org
 http://www.haskell.org/mailman/listinfo/beginners




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


Re: [Haskell-cafe] How to select n random words from a file ...

2012-06-10 Thread KC
An interesting related problem is if you are only allowed one pass through
the data how would you randomly choose one word.





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


[Haskell-cafe] Found quote: One of the ineradicable illusions about C++ is that the compiler should be able to see through ...

2012-05-23 Thread KC
all the abstractions and obfuscations an “advanced” C++ program contains.
First and foremost, C++ should be seen as a language that enables complexity
management. The features one has grown fond of in this concept, like
operator
overloading, object orientation, automatic construction/destruction, etc.,
are however
mostly unsuitable for efficient low-level code.

From Introduction to High Performance Computing for Scientists and
Engineers CRC Press, 2011.

So if one avoids such C++ complexity management features and a Haskell
compiler can see through most of the complexity management features of
Haskell; they should be comparable. :)


Casey

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


[Haskell-cafe] Most C++ compilers will not optimize x^2.0 as x*x but instead will do an expensive ...

2012-05-23 Thread KC
exponentiation and logarithm.

So, I believe this C++ versus Haskell versus (your language of choice) is a
Penn  Teller misdirection.

Whereas, another level of indirection solves everything.

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


[Haskell-cafe] From some High-Performance Computing book; It is hard to eradicate from C++'ers the need for objects, classes, etc. ...

2012-05-22 Thread KC
For high-performance computing you want to avoid such software engineering
abstractions as classes, objects, etc

Therefore, I would say, since Haskell makes possible many fine-levels of
abstraction, if the compiler can strip most of these away, then it would
come close to the speed of C (i.e. C++ without most of the software
engineering abstractions).


Still, I remember that quote that, Another level of indirection solves
everything.

Or

If you're Penn  Teller, Another level of misdirection solves everything.

Casey

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


[Haskell-cafe] I am having trouble with the type declaration for creating an identity matrix.

2012-04-24 Thread KC
initIdentityMat :: Int - ST s (STUArray s (Int,Int) ((Int, Int), Double))
initIdentityMat m = newListArray ((1,m),(1,m)) ([((i,j), if i == j then 1.0
else 0.0) | i - [1..m], j - [1..m]] :: [((Int,Int), Double)])

Doesn't seem to compile, nor do minor variations of the type declaration.

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


Re: [Haskell-cafe] I am having trouble with the type declaration for creating an identity matrix.

2012-04-24 Thread KC
Thank you.

One is ONLY supposed to supply the list elements for newListArray which
fill the array in increasing order.


On Tue, Apr 24, 2012 at 3:21 PM, Kevin Charter kchar...@gmail.com wrote:

 On Tue, Apr 24, 2012 at 3:20 PM, KC kc1...@gmail.com wrote:

 initIdentityMat :: Int - ST s (STUArray s (Int,Int) ((Int, Int), Double))
 initIdentityMat m = newListArray ((1,m),(1,m)) ([((i,j), if i == j then
 1.0 else 0.0) | i - [1..m], j - [1..m]] :: [((Int,Int), Double)])

 Doesn't seem to compile, nor do minor variations of the type declaration.


 If you use Hoogle to find the type and API docs for 'newListArray', I
 believe you'll be able to figure out what's wrong, but I'll give you a
 hint. The list you're giving to 'newListArray' contains too much; and the
 pair you give it is only half correct.

 Kevin

 --
 Kevin Charter
 kevin.char...@acm.org




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


[Haskell-cafe] Is it only one data structure per ST monad?

2012-04-23 Thread KC
Is it only one data structure per ST monad?

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


[Haskell-cafe] (no subject)

2012-04-23 Thread KC
buildPair =
do
arr - newArray ((1,1),(1,10)) 37 :: ST s (STArray s (Int,Int) Int)
a - readArray arr (1,1)
writeArray arr (1,1) 64
b - readArray arr (1,1)
return (a,b)


main = print $ runST buildPair


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


[Haskell-cafe] The last statement in a 'do' construct must be an expression: a - readArray arr (1, 1)

2012-04-23 Thread KC
I'm getting the above error message and I cannot figure out why?


buildPair =
do
arr - newArray ((1,1),(1,10)) 37 :: ST s (STArray s (Int,Int) Int)
a - readArray arr (1,1)
writeArray arr (1,1) 64
b - readArray arr (1,1)
return (a,b)


main = print $ runST buildPair


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


Re: [Haskell-cafe] The last statement in a 'do' construct must be an expression: a - readArray arr (1, 1)

2012-04-23 Thread KC
Thank you, that was it.

I was mixing up and tabs and spaces.

I expected new versions of NotePad++ to keep my old settings.


On Mon, Apr 23, 2012 at 1:54 PM, Ryan Yates fryguy...@gmail.com wrote:

 Perhaps you are mixing tabs and spaces?

 On Mon, Apr 23, 2012 at 4:52 PM, KC kc1...@gmail.com wrote:

 I'm getting the above error message and I cannot figure out why?


 buildPair =
 do
 arr - newArray ((1,1),(1,10)) 37 :: ST s (STArray s (Int,Int) Int)
  a - readArray arr (1,1)
 writeArray arr (1,1) 64
 b - readArray arr (1,1)
 return (a,b)


 main = print $ runST buildPair


 --
 --
 Regards,
 KC

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





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


Re: [Haskell-cafe] why are applicative functors (often) faster than monads? (WAS Google Summer of Code - Lock-free data structures)

2012-04-20 Thread KC
Think of the differences (and similarities) of Applicative Functors and
Monads and the extra context that monads carry around.


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


Re: [Haskell-cafe] why are applicative functors (often) faster than monads? (WAS Google Summer of Code - Lock-free data structures)

2012-04-20 Thread KC
Sorry, I thought you or someone was asking why are Applicative Functors
faster in general than Monads.

Functional programming is structured function calling to achieve a result
where the functions can be evaluated in an unspecified order; I
thought Applicative Functors had the same unspecified evaluation order;
whereas, Monads could carry some sequencing of computations which has the
extra overhead of continuation passing.

Do I have that correct?


On Fri, Apr 20, 2012 at 4:05 PM, Ben midfi...@gmail.com wrote:

 i'm not sure what your email is pointing at.  if it is unclear, i
 understand the difference between applicative and monadic.  i suppose the
 easy answer to why applicative can be faster than monadic is that you can
 give a more specialized instance declaration.  i was just wondering if
 there was a way to make a monad recognize when it is being used
 applicatively, but that is probably hard in general.

 b

 On Apr 20, 2012, at 2:54 PM, KC wrote:

  Think of the differences (and similarities) of Applicative Functors and
 Monads and the extra context that monads carry around.
 
 
  --
  --
  Regards,
  KC




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


Re: [Haskell-cafe] I Need a Better Functional Language!

2012-04-05 Thread KC
On Thu, Apr 5, 2012 at 11:59 AM, Tillmann Rendel 
ren...@informatik.uni-marburg.de wrote:

 Paul R wrote:

 I am curious what are interesting use-cases for that? Symbolic
 analysis? self-compilers?


 Optimization. For example, imagine the following definition of function
 composition:

  map f . map g = map (f . g)
  f . g = \x - f (g x)

 In Haskell, we cannot write this, because we cannot pattern match on
 function calls.

  Tillmann

 So, we're not talking about optimization as in Mathematical Programming
but optimization in language constructs.

You might want to take a look at MIN by Stephen Tse.

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


Re: [Haskell-cafe] Theoretical question: are side effects necessary?

2012-03-17 Thread KC
Apparently on such solid ground that you hinder their critical thinking
skills by answering for them.


On Fri, Mar 16, 2012 at 9:24 PM, Donn Cave d...@avvanta.com wrote:
 Quoth KC kc1...@gmail.com,

 On Fri, Mar 16, 2012 at 7:44 PM, Jerzy Karczmarczuk
 jerzy.karczmarc...@unicaen.fr wrote:

 ... but the question of purity of a program - in my opinion - concerns
 the program, and nothing else.

 You might be thinking of software engineering purity.

 Or software engineers might be thinking of purity in the same way.
 I personally hope I think of purity in a way that's of some practical
 use in terms of Haskell programs, and I would hope software engineers
 in general would do likewise.  From that perspective, it seems to me
 that M. Karczmarczuk is on pretty solid ground.

Donn



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


[Haskell-cafe] In Haskell, because of the fine layers of abstraction that are possible, it pays to hone one's critical thinking skills.

2012-03-17 Thread KC
-- 
--
Regards,
KC
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] In an imperative language, commands fulling memory cells is easy, but gives the false impression that S/W engineering is easy.

2012-03-17 Thread KC
-- 
--
Regards,
KC
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Are side effects necessary is a non question; you compute so as to change the state of the world.

2012-03-16 Thread KC
Casey

-- 
--
Regards,
KC

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


[Haskell-cafe] The Theoretical Question would be; are side effects necessary for computational heavy lifting.

2012-03-16 Thread KC
Casey

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Theoretical question: are side effects necessary?

2012-03-16 Thread KC
On Fri, Mar 16, 2012 at 7:44 PM, Jerzy Karczmarczuk
jerzy.karczmarc...@unicaen.fr wrote:

... but the question of purity of a program - in my opinion - concerns the 
program, and nothing else.

You might be thinking of software engineering purity.


The networking is not expected to break the referential transparency, or does 
it?


 Jerzy Karczmarczuk


What does referential transparency mean to you?


-- 
--
Regards,
KC

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


[Haskell-cafe] I've just heard of a neat security measure that when you compile the code it generates different object code...

2011-12-16 Thread KC
... with the same functionality.

Thus, your program would be a moving target to hackers.

Would this be challenging with ghc?

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Quicksort in Haskell

2011-11-07 Thread KC
What is your question?



On Mon, Nov 7, 2011 at 9:45 AM, yrazes yra...@gmail.com wrote:
 module Main (main) where
 quicksort [] = []
 quicksort (s:xs) = quicksort [x|x - xs,x  s] ++ [s] ++ quicksort [x|x -
 xs,x = s]
 main = putStr Ingrese la lista\n
        [xs] - getLine
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe





-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Best bit LIST data structure

2011-10-09 Thread KC
Must it be a list?

What about a Bloom Filter?

On Sun, Oct 9, 2011 at 9:11 AM, Roman Beslik ber...@ukr.net wrote:
 Yes, if you do not use high-level concepts and optimize everything by hand,
 it requires a lot of testing. :)

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




-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-30 Thread KC
You might like this zipping  folding version.

Explicit recursion has the disadvantage that one has to read the
entire function in order to figure out what's going on; whereas using
the higher order functions makes things much easier to grasp.

listof4tuples xs = (zip4 xs (tail xs) (tail (tail xs)) (tail (tail (tail xs

prods xs = map prods4 (listof4tuples xs)

prods4 (t,u,v,w) = t*u*v*w

maxprods4 xs = maximum $ prods xs

On Mon, Aug 29, 2011 at 9:40 AM, Oscar Picasso oscarpica...@gmail.com wrote:
 Got it.

 f :: [Int] - Int
 f (t:u:v:xs) = helper t u v xs

 helper :: Int - Int - Int - [Int] - Int
 helper t u v (w:ws)
  | ws == []  = t*u*v*w
  | otherwise = max (t*u*v*w) (f (u:v:w:ws))

 I tend to overlook mutual recursion in my toolbox.

 Thanks for the nnlightenment.

 On Sun, Aug 28, 2011 at 4:54 PM, KC kc1...@gmail.com wrote:
 Try something like the following:

 -- Project Euler 11

 -- In the 20×20 grid below, four numbers along a diagonal line have
 been marked in red.

 -- snip

 -- The product of these numbers is 26 × 63 × 78 × 14 = 1788696.

 -- What is the greatest product of four adjacent numbers in any
 direction (up, down, left, right, or diagonally) in the 20×20 grid?


 import Data.List

 -- Doing the one dimensional case.
 f011 :: [Int] - Int
 f011 (t:u:v:xs) = f011helper t u v xs

 f011helper :: Int - Int - Int - [Int] - Int
 f011helper t u v (w:ws)
    | ws == []  = t*u*v*w
    | otherwise = yada nada mada

 -- What are yada nada mada?

 -- The 20x20 grid case will become:
 f0112D :: [[Int]] - Int
 -- where [[Int]] is a list of lists of rows, columns, major diagonals,
  minor diagonals.




 On Sun, Aug 28, 2011 at 5:10 AM, Oscar Picasso oscarpica...@gmail.com 
 wrote:
 No. The answer I posted is not good.
 It worked, by chance, on a couple of small examples I tried but it
 could end up comparing sequence of 4 numbers that where not initially
 adjacent.

 On Sun, Aug 28, 2011 at 12:32 AM, Oscar Picasso oscarpica...@gmail.com 
 wrote:
 Maybe this?

 f x@(a:b:c:d:[]) = x
 f (a:b:c:d:e:ys)  = if e = a
                   then f (b:c:d:e:ys)
                   else f (a:b:c:d:ys)

 On Sat, Aug 27, 2011 at 8:26 PM, KC kc1...@gmail.com wrote:
 Think of the simplest version of the problem that isn't totally trivial.

 e.g. A one dimensional list of numbers.

 What would you do?

 Note: you only want to touch each element once.

 The 2 dimensional case could be handled by putting into lists: rows,
 columns, major diagonals, and minor diagonals.

 This isn't the fastest way of doing the problem but it has the
 advantage of avoiding indexitis.


 On Fri, Aug 26, 2011 at 6:15 PM, Oscar Picasso oscarpica...@gmail.com 
 wrote:
 Like:
 20*19*21*18
 is bigger than
 100*100*3*2
 ?

 If so I need to think about how to formalize it.

 Thanks for the hint.

 On Fri, Aug 26, 2011 at 8:55 PM, KC kc1...@gmail.com wrote:
 Is Problem 11 the 4 consecutive #'s problem?

 If so what must be true for 4 #'s to have a large product?

 Hint: x * y * z * 2 is that going to be larger?

 --
 --
 Regards,
 KC





 --
 --
 Regards,
 KC






 --
 --
 Regards,
 KC





-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Off-topic: Mathematics and modesty

2011-08-30 Thread KC
He said Trying to distinguish first between knowledgeable, wise,
guru, wizard, etc. before asking the actual mathematics related
question.

Beware: the expert
X is an unknown quantity
spert is a drip under pressure
:D


On Tue, Aug 30, 2011 at 12:16 PM, Chris Smith cdsm...@gmail.com wrote:
 On Tue, 2011-08-30 at 20:58 +0200, Jerzy Karczmarczuk wrote:
 With all my respect:
 I think I know several mathematicians who learning that a person asking
 for help begins with trying to distinguish  between knowledgeable, and
 those who just think they are, will simply - to say it politely - refuse
 to engage.

 I don't agree with this.  It's the most natural thing in the world to
 listen to an answer and then try to figure out whether the speaker knows
 what they are talking about or not.  Those who expect us to forego that
 step aren't really engaged in mathematics any more.

 --
 Chris Smith


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




-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-30 Thread KC
You also don't need mutual recursion for this explicit recursion since
I imagine it would use up more stack space.


-- Doing the one dimensional case.
f011 :: [Int] - Int
f011 (t:u:v:xs) = f011helper t u v xs

f011helper :: Int - Int - Int - [Int] - Int
f011helper t u v (w:ws)
| ws == []  = t*u*v*w
| otherwise = max (t*u*v*w) (f011helper u v w ws)


-- Note: f011helper does not call f011.


On Mon, Aug 29, 2011 at 9:40 AM, Oscar Picasso oscarpica...@gmail.com wrote:
 Got it.

 f :: [Int] - Int
 f (t:u:v:xs) = helper t u v xs

 helper :: Int - Int - Int - [Int] - Int
 helper t u v (w:ws)
  | ws == []  = t*u*v*w
  | otherwise = max (t*u*v*w) (f (u:v:w:ws))

 I tend to overlook mutual recursion in my toolbox.

Good going! :)


 Thanks for the enlightenment.

 On Sun, Aug 28, 2011 at 4:54 PM, KC kc1...@gmail.com wrote:
 Try something like the following:

 -- Project Euler 11

 -- In the 20×20 grid below, four numbers along a diagonal line have
 been marked in red.

 -- snip

 -- The product of these numbers is 26 × 63 × 78 × 14 = 1788696.

 -- What is the greatest product of four adjacent numbers in any
 direction (up, down, left, right, or diagonally) in the 20×20 grid?


 import Data.List

 -- Doing the one dimensional case.
 f011 :: [Int] - Int
 f011 (t:u:v:xs) = f011helper t u v xs

 f011helper :: Int - Int - Int - [Int] - Int
 f011helper t u v (w:ws)
    | ws == []  = t*u*v*w
    | otherwise = yada nada mada

 -- What are yada nada mada?

 -- The 20x20 grid case will become:
 f0112D :: [[Int]] - Int
 -- where [[Int]] is a list of lists of rows, columns, major diagonals,
  minor diagonals.


-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-28 Thread KC
Try something like the following:

-- Project Euler 11

-- In the 20×20 grid below, four numbers along a diagonal line have
been marked in red.

-- snip

-- The product of these numbers is 26 × 63 × 78 × 14 = 1788696.

-- What is the greatest product of four adjacent numbers in any
direction (up, down, left, right, or diagonally) in the 20×20 grid?


import Data.List

-- Doing the one dimensional case.
f011 :: [Int] - Int
f011 (t:u:v:xs) = f011helper t u v xs

f011helper :: Int - Int - Int - [Int] - Int
f011helper t u v (w:ws)
   | ws == []  = t*u*v*w
   | otherwise = yada nada mada

-- What are yada nada mada?

-- The 20x20 grid case will become:
f0112D :: [[Int]] - Int
-- where [[Int]] is a list of lists of rows, columns, major diagonals,
 minor diagonals.



On Sun, Aug 28, 2011 at 5:10 AM, Oscar Picasso oscarpica...@gmail.com wrote:
 No. The answer I posted is not good.
 It worked, by chance, on a couple of small examples I tried but it
 could end up comparing sequence of 4 numbers that where not initially
 adjacent.

 On Sun, Aug 28, 2011 at 12:32 AM, Oscar Picasso oscarpica...@gmail.com 
 wrote:
 Maybe this?

 f x@(a:b:c:d:[]) = x
 f (a:b:c:d:e:ys)  = if e = a
                   then f (b:c:d:e:ys)
                   else f (a:b:c:d:ys)

 On Sat, Aug 27, 2011 at 8:26 PM, KC kc1...@gmail.com wrote:
 Think of the simplest version of the problem that isn't totally trivial.

 e.g. A one dimensional list of numbers.

 What would you do?

 Note: you only want to touch each element once.

 The 2 dimensional case could be handled by putting into lists: rows,
 columns, major diagonals, and minor diagonals.

 This isn't the fastest way of doing the problem but it has the
 advantage of avoiding indexitis.




-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-28 Thread KC
I just noticed that the 20x20 grid has some 00 entries; thus, time
could be saved by not touching any of the grid entries 3 cells away.
Same for the 01 entries.

The challenge, of course, is in finding these entries in the first place. :)


On Sun, Aug 28, 2011 at 1:58 PM, KC kc1...@gmail.com wrote:
 Try something like the following:

 -- Project Euler 11

 -- In the 20×20 grid below, four numbers along a diagonal line have
 been marked in red.

 -- snip

 -- The product of these numbers is 26 × 63 × 78 × 14 = 1788696.

 -- What is the greatest product of four adjacent numbers in any
 direction (up, down, left, right, or diagonally) in the 20×20 grid?


 import Data.List

 -- Doing the one dimensional case.
 f011 :: [Int] - Int
 f011 (t:u:v:xs) = f011helper t u v xs

 f011helper :: Int - Int - Int - [Int] - Int
 f011helper t u v (w:ws)
   | ws == []  = t*u*v*w
   | otherwise = yada nada mada

 -- What are yada nada mada?

 -- The 20x20 grid case will become:
 f0112D :: [[Int]] - Int
 -- where [[Int]] is a list of lists of rows, columns, major diagonals,
  minor diagonals.



 On Sun, Aug 28, 2011 at 5:10 AM, Oscar Picasso oscarpica...@gmail.com wrote:
 No. The answer I posted is not good.
 It worked, by chance, on a couple of small examples I tried but it
 could end up comparing sequence of 4 numbers that where not initially
 adjacent.

 On Sun, Aug 28, 2011 at 12:32 AM, Oscar Picasso oscarpica...@gmail.com 
 wrote:
 Maybe this?

 f x@(a:b:c:d:[]) = x
 f (a:b:c:d:e:ys)  = if e = a
                   then f (b:c:d:e:ys)
                   else f (a:b:c:d:ys)

 On Sat, Aug 27, 2011 at 8:26 PM, KC kc1...@gmail.com wrote:
 Think of the simplest version of the problem that isn't totally trivial.

 e.g. A one dimensional list of numbers.

 What would you do?

 Note: you only want to touch each element once.

 The 2 dimensional case could be handled by putting into lists: rows,
 columns, major diagonals, and minor diagonals.

 This isn't the fastest way of doing the problem but it has the
 advantage of avoiding indexitis.




 --
 --
 Regards,
 KC




-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-27 Thread KC
Think of the simplest version of the problem that isn't totally trivial.

e.g. A one dimensional list of numbers.

What would you do?

Note: you only want to touch each element once.

The 2 dimensional case could be handled by putting into lists: rows,
columns, major diagonals, and minor diagonals.

This isn't the fastest way of doing the problem but it has the
advantage of avoiding indexitis.


On Fri, Aug 26, 2011 at 6:15 PM, Oscar Picasso oscarpica...@gmail.com wrote:
 Like:
 20*19*21*18
 is bigger than
 100*100*3*2
 ?

 If so I need to think about how to formalize it.

 Thanks for the hint.

 On Fri, Aug 26, 2011 at 8:55 PM, KC kc1...@gmail.com wrote:
 Is Problem 11 the 4 consecutive #'s problem?

 If so what must be true for 4 #'s to have a large product?

 Hint: x * y * z * 2 is that going to be larger?

 --
 --
 Regards,
 KC





-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-26 Thread KC
Is Problem 11 the 4 consecutive #'s problem?

If so what must be true for 4 #'s to have a large product?

Hint: x * y * z * 2 is that going to be larger?

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] why the name lambda calculus?

2011-08-23 Thread KC
See Serge Lang's Algebra.


2011/8/23 Rajesh S R srrajesh1...@gmail.com:
 Slight digression. Why not Lambda Algebra?
 In particular, what is the criteria for a system to be calculus and how's it
 different from algebra?



-- 
--
Regards,
KC

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


Re: [Haskell-cafe] why the name lambda calculus?

2011-08-22 Thread KC
Definition of calculus

a : a method of computation or calculation in a special notation (as
of logic or symbolic logic)

b : the mathematical methods comprising differential and integral
calculus —often used with the

So a calculus means more than differentiation and integration it can
also mean a system of symbols that can be mechanistically modified;
algorithmically modified if you prefer.


Lambda abstraction was probably chosen in case someone found better
abstractions; e.g. epsilon, delta, gamma, beta, alpha, ... :)

Or Joel Spolsky's leaky abstractions. :D


On Sun, Aug 21, 2011 at 9:37 AM, C K Kashyap ckkash...@gmail.com wrote:
 Hi,
 Can someone please tell me what is the root of the name lambda calculus? Is
 it just because of the symbol lambda that is used?
 Why not alpha or beta calculus?
 Regards,
 Kashyap
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe





-- 
--
Regards,
KC

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


Re: [Haskell-cafe] why the name lambda calculus?

2011-08-22 Thread KC
I had thyroid cancer a few years ago; now I've lost my sense of tumour. :)


-- 
--
Regards,
KC

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


Re: [Haskell-cafe] [Haskell-beginners] Conciseness question

2011-08-08 Thread KC
Sorry, I haven't read all the replies so I don't know if you have
completely described the problem you're trying to solve; however, it
might be better for people in future to say they want O(1) for
insertions, O(lg n) for searching, etc.

If they don't want to completely describe what their problem is.





-- 
--
Regards,
KC

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


Re: [Haskell-cafe] For class Monoid; better names than mempty mappend might have been: mid (mident) mbinop

2011-08-08 Thread KC
 As pointed out earlier in this list, the name of the class and the methods
 are inconsistent.
 Monoid refers to a general algebraic structure, whereas
 mempty and mappend refer to certain instances like lists.


Thank you for articulating what I was trying to get at.


-- 
--
Regards,
KC

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


[Haskell-cafe] Is there a program to check if a matrix is totally unimodular?

2011-08-03 Thread KC
-- 
--
Regards,
KC

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


[Haskell-cafe] A language that runs on the JVM or .NET has the advantage of Oracle Microsoft making those layers more parallelizable.

2011-07-30 Thread KC
Are there plans a foot (or under fingers) to make a version of Haskell
that runs on the JVM?

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] For class Monoid; better names than mempty mappend might have been: mid (mident) mbinop

2011-07-24 Thread KC
I like the following but again + denotes addition and not a general
binary operation.


 I personally often define the alias:

 (+) = mappend

A lot of math books use + or x enclosed in a circle to indicate
that the usual meaning of + nor x is intended for the meaning of
the binary operation.

I can't figure out if this would compile, the inside () representing a circle.

((+)) = mappend




It would be easier for beginners to grok.

I don't think so... but while we're at it, what's with that weird name
Monoid anyway, let alone Functor, Monad, etc.? ;-)

Ivan: I had thought those were words expressing valid mathematical concepts.

In order to find similarities between apparently different operations
 data one wants to reason abstractly; similar to mathematics.

-- 
--
Regards,
KC

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


[Haskell-cafe] For class Monoid; better names than mempty mappend might have been: mid (mident) mbinop

2011-07-23 Thread KC
It would be easier for beginners to grok.

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Call for GUI examples - Functional Reactive Programming

2011-07-08 Thread KC
Can one do FRP with Haskell connected to Javascript in the browser? I
believe there is a standalone version of Javascript.

On 7/8/11, Heinrich Apfelmus apfel...@quantentunnel.de wrote:
 Chris Smith wrote:
 Heinrich Apfelmus wrote:
 Do you know any *small GUI programs* that you would *like* to see
 *implemented with Functional Reactive Programming?*

 This isn't really a specific application, but what I'd like to see most
 from FRP is an example of something that involves moving between windows
 and dialog boxes.  All of the GUI-based FRP examples I've seen so far
 involve interactions in a specific GUI layout.  It's unclear to me how
 FRP extends into a situation like:

 - There's a starting window showing several options for what to do
 - When the user chooses an option, that window closes, and a new one
 opens with that activity.
 - In response to some actions, dialog boxes appear with their own
 interactions.

 It's not clear to me if anyone in FRP has an idea of how stuff like this
 fits in.  Is there some FRP trick to handle this declaratively?  Or
 would you just say each move to a new window ends or pauses one network
 of events and behaviors, and starts a new one?

 That's a very good example. Unfortunately, I am one of those who don't
 have any idea of how stuff like this fits in. :)

 I think it's possible to get something like this with pausing and
 resuming event networks, but a general and elegant formulation would
 probably rely on dynamic event switching, which I haven't attempted to
 implement yet. I'm trying to pick the low hanging fruit first.


 Best regards,
 Heinrich Apfelmus

 --
 http://apfelmus.nfshost.com


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



-- 
--
Regards,
KC

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


[Haskell-cafe] Can one drop GHC 7.0.4 into the Haskell Platform or does the platform need to be updated?

2011-06-16 Thread KC
-- 
--
Regards,
KC

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


[Haskell-cafe] Haskell: The Craft of Functional Programming 3rd ed is out.

2011-06-16 Thread KC
http://www.haskellcraft.com/craft3e/Home.html

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Dead else branch does influence runtime?

2011-06-14 Thread KC
How is the compiler to know the else branch is never executed at run-time?

If you do, then why is it there in your source code?


On Tue, Jun 14, 2011 at 7:35 AM, Johannes Waldmann
waldm...@imn.htwk-leipzig.de wrote:
 Thanks for the analysis.

 So is this a problem that should be fixed in GHC?

 And what can I do to circumvent the problem?
 (Perhaps write some RULES magic?)

 Thanks - J.W.


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




-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Dead else branch does influence runtime?

2011-06-14 Thread KC
Superb; on how to avoid boxing.

On Tue, Jun 14, 2011 at 7:51 AM, Daniel Fischer
daniel.is.fisc...@googlemail.com wrote:
 On Tuesday 14 June 2011, 15:51:57, Daniel Fischer wrote:
 On Tuesday 14 June 2011, 14:35:19, Johannes Waldmann wrote:


 With id, main1 jumps to foldb_cap, which contains a lot of code for the
 (cap  1)-branch, and - that's what causes the slowdown - a worker loop

 $s$wfoldlM'_loop_s3EE [Occ=LoopBreaker]

             :: GHC.Prim.Int#

                - (GHC.Types.Int, GHC.Types.Int)
                - (# GHC.Types.Int, GHC.Types.Int #)

 which uses the passed functions (thus you have no inlining of eff and
 h1, and a boxed tuple of boxed Int's in your worker).

  I am sure GHC headquarters will look at this when they find the time
  but perhaps there's some additional knowledge on this mailing list
  that might help.

 Note that you get good behaviour when you help GHC a bit, in particular a
 static argument transformation for the function parameters of foldb_cap
 allows them to be inlined and (in this case) you get the nice loop on
 unboxed Int#s again:


 foldb_cap :: ( V.Unbox a, V.Unbox b )
      = Int
      - b
      - ( a - b )
      - ( b - b - b )
      - Vector a
      - b
 foldb_cap cp strt f g xs = work cp strt xs
  where
    work cap e s =
      if cap = 1
      then V.foldl' g e $ V.map f s
         -- replace id by undefined in the following,
         -- and notice a drastic decrease in runtime -
         -- although this branch is never executed:
      else id $ case V.length s of
        0 - e
        1 - f $! V.head s
        n - let splitAt k v =
                       ( V.take k v, V.drop k v )
                 ( s1, s2 ) = splitAt ( div n 2 ) s
                 cap' = div cap 2
                 v1 = work cap' e s1
                 v2 = work cap' e s2
                 v = g v1 v2
             in par v1 $ pseq v2 $ v



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




-- 
--
Regards,
KC

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


[Haskell-cafe] In ML books; functors only consume produce structures; whereas, functions CP values.

2011-06-10 Thread KC
I've never seen such an easy description in Haskell books.

Is there more going on with Haskell functors?

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Can it be proven there are no intermediate useful type classes between Applicative Functors Monads?

2011-06-06 Thread KC
On Mon, Jun 6, 2011 at 9:19 AM, Brent Yorgey byor...@seas.upenn.edu wrote:
 On Sun, Jun 05, 2011 at 12:51:47PM -0700, KC wrote:
 If new intermediate classes crop up then there would be no point in fixing

 class (Applicative m) = Monad m where

 since it would have to be changed if new intermediate classes are
 found.

 There actually is at least one intermediate class that I know of,

  class Applicative m = Branching m where
    branch :: m Bool - m a - m a - m a

 subject to the laws

  branch (m * pure True)  t f == m * t
  branch (m * pure False) t f == m * f

 or something like that.  The idea is that Applicative computations
 have a fixed structure which is independent of intermediate results;
 Monad computations correspond to (potentially) infinitely branching
 trees, since intermediate results (which could be of an infinite-sized
 type) can be used to compute the next action; but Branching
 computations correspond to *finitely* branching trees, since future
 computation can depend on intermediate results, but only one binary
 choice at a time.

 However, I doubt this qualifies as useful no matter how you define
 it, although I would not be sad to be proven wrong.  In any case, I
 think it is ethically indefensible to procrastinate in doing something
 good just in case you might miss an opportunity to do something
 perfect later.

 -Brent


I take it you would prefer the following signature

class (Applicative m) = Monad m where


-- 
--
Regards,
KC

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


[Haskell-cafe] Can it be proven there are no intermediate useful type classes between Applicative Functors Monads?

2011-06-05 Thread KC
If new intermediate classes crop up then there would be no point in fixing

class (Applicative m) = Monad m where

since it would have to be changed if new intermediate classes are found.

I realize non-existence proofs are hard.

-- 
--
Regards,
KC

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


[Haskell-cafe] I'm trying to install the Haskell Platform on a Mac and ...

2011-06-05 Thread KC
I'm trying to install the Haskell Platform on a Mac and I've already
installed Xcode 3.2.6 but the platform says that the tools are not
installed. Do I need to reboot?

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] I'm trying to install the Haskell Platform on a Mac and ...

2011-06-05 Thread KC
Never mind.

I didn't realize there were two steps:
- clicking on the dmg file
- then actualling installing the software

On Sun, Jun 5, 2011 at 1:20 PM, KC kc1...@gmail.com wrote:
 I'm trying to install the Haskell Platform on a Mac and I've already
 installed Xcode 3.2.6 but the platform says that the tools are not
 installed. Do I need to reboot?

 --
 --
 Regards,
 KC




-- 
--
Regards,
KC

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


[Haskell-cafe] OK! I have a Mac with Snow Leopard 10.6.7?, Xcode 3.2.6, Haskell Platform 2011.2.0.1; What are 2or 3 ways so far to get a GUI graphics?

2011-06-05 Thread KC
-- 
--
Regards,
KC

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-23 Thread KC
Librarians have been struggling for years with classifying topics; I
don't imagine classifying coding libraries as any easier. :)




-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Is there an efficient way to generate Euler's totient function for [2, 3..n]?

2011-05-22 Thread KC
 It's declarative and may help to verify more efficient implementations.

WOW! Good insight. :)


On Sun, May 22, 2011 at 9:27 AM, Henning Thielemann
schlepp...@henning-thielemann.de wrote:
 Daniel Fischer schrieb:

 On Saturday 14 May 2011 19:38:03, KC wrote:
 Instead of finding the totient of one number, is there a quicker way
 when processing a sequence?

 For some sequences.

 You may find alternative ways of computation in the Online Encyclopedia
 of Integer Sequences.

 http://oeis.org/A10

 -- From: http://www.haskell.org/haskellwiki/99_questions/Solutions/34
 totient :: Int - Int
 totient n = length [x | x - [1..n], coprime x n]
    where
    coprime a b = gcd a b == 1

 NEVER do that! It's awfully slow.

 It's declarative and may help to verify more efficient implementations.


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




-- 
--
Regards,
KC

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


[Haskell-cafe] Is there a place where we can have a discussion on the merits of various GUI's various graphics? And then vote?

2011-05-20 Thread KC
:)

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Is there a place where we can have a discussion on the merits of various GUI's various graphics? And then vote?

2011-05-20 Thread KC
So we can get this show on the road.  Pun intended. :D

On Fri, May 20, 2011 at 12:20 PM, KC kc1...@gmail.com wrote:
 :)




-- 
--
Regards,
KC

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


[Haskell-cafe] In several chapters there is a penetrating conceptual analysis of the matter at hand, on which a superstructure of code is erected.

2011-05-20 Thread KC
Interesting comment on the book The Fun of Programming in JOOP.

In several chapters there is a penetrating conceptual analysis of the
matter at hand, on which a superstructure of code is erected.

-- 
--
Regards,
KC

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


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

2011-05-20 Thread KC
Extension for Pearls of Functional Algorithm Design by Richard Bird,
2010, page 25 #Haskell

---
---

module SelectionProblem where

import Data.Array
import Data.List


---
---

-- Question: is there a way to get the type signature as the following:
-- smallest :: (Ord a) = Int - [Array Int a] - a

---
---


-- Works on 2 finite ordered disjoint sets represented as sorted arrays.
smallest :: (Ord a) = Int - (Array Int a, Array Int a) - a
smallest k (xa,ya) =
search k (xa,ya) (0,m+1) (0,n+1)
where
(0,m) = bounds xa
(0,n) = bounds ya


-- Removed some of the indexitis at the cost of calling another function.
search :: (Ord a) = Int - (Array Int a, Array Int a) - (Int,Int) -
(Int,Int) - a
search k (xa,ya) (lx,rx) (ly,ry)
| lx == rx  = ya ! (k+ly)
| ly == ry  = xa ! (k+lx)
| otherwise = case (xa ! mx  ya ! my) of
  (True)- smallest2h k (xa,ya) ((lx,mx,rx),(ly,my,ry))
  (False)   - smallest2h k (ya,xa) ((ly,my,ry),(lx,mx,rx))
  where
  mx = (lx+rx) `div` 2
  my = (ly+ry) `div` 2


-- Here the sorted arrays are in order by their middle elements.
-- Only cutting the leading or trailing array by half.

-- Here xa is the first array and ya the second array by their middle elements.

smallest2h :: (Ord a) = Int - (Array Int a, Array Int a) -
((Int,Int,Int),(Int,Int,Int)) - a
smallest2h k (xa,ya) ((lx,mx,rx),(ly,my,ry)) =
case (k=mx-lx+my-ly) of
  (True)- search k (xa,ya) (lx,rx) (ly,my)
  (False)   - search (k-(mx-lx)-1) (xa,ya) (mx+1,rx) (ly,ry)


---
---

-- Works on 3 finite ordered disjoint sets represented as sorted arrays.

smallest3 :: (Ord a) = Int - (Array Int a, Array Int a, Array Int a) - a
smallest3 k (xa,ya,za) =
-- On each recursive call the order of the arrays can switch.
search3 k (xa,ya,za) (0,bx+1) (0,by+1) (0,bz+1)
where
(0,bx) = bounds xa
(0,by) = bounds ya
(0,bz) = bounds za


-- Removed some of the indexitis at the cost of calling another function.
search3 :: (Ord a) = Int - (Array Int a, Array Int a, Array Int a) -
(Int,Int) - (Int,Int) - (Int,Int) - a
search3 k (xa,ya,za) (lx,rx) (ly,ry) (lz,rz)
| lx == rx  ly == ry  = za ! (k+lz)
| ly == ry  lz == rz  = xa ! (k+lx)
| lx == rx  lz == rz  = ya ! (k+ly)

| lx == rx  = search k (ya,za) (ly,ry) (lz,rz)
| ly == ry  = search k (xa,za) (lx,rx) (lz,rz)
| lz == rz  = search k (xa,ya) (lx,rx) (ly,ry)

| otherwise = case (xa ! mx  ya ! my, xa ! mx  za ! mz, ya ! my
 za ! mz) of
  (True, True, True)- smallest3h k (xa,ya,za)
((lx,mx,rx),(ly,my,ry),(lz,mz,rz)) -- abc
  (True, True, False)   - smallest3h k (xa,za,ya)
((lx,mx,rx),(lz,mz,rz),(ly,my,ry)) -- acb
  (False, True, True)   - smallest3h k (ya,xa,za)
((ly,my,ry),(lx,mx,rx),(lz,mz,rz)) -- bac
  (False, False, True)  - smallest3h k (ya,za,xa)
((ly,my,ry),(lz,mz,rz),(lx,mx,rx)) -- bca
  (True, False, False)  - smallest3h k (za,xa,ya)
((lz,mz,rz),(lx,mx,rx),(ly,my,ry)) -- cab
  (False, False, False) - smallest3h k (za,ya,xa)
((lz,mz,rz),(ly,my,ry),(lx,mx,rx)) -- cba

  where
  mx = (lx+rx) `div` 2
  my = (ly+ry) `div` 2
  mz = (lz+rz) `div` 2


-- Here the sorted arrays are in order by their middle elements.
-- Only cutting the leading or trailing array by half.

-- Here xa is the first array, ya the second array, and za the third
array by their middle elements.
smallest3h :: (Ord a) = Int - (Array Int a, Array Int a, Array Int a) -
((Int,Int,Int),(Int,Int,Int),(Int,Int,Int)) - a
smallest3h k (xa,ya,za) ((lx,mx,rx),(ly,my,ry),(lz,mz,rz)) =
case (k=mx-lx+my-ly+mz-lz) of
  (True)- search3 k (xa,ya,za) (lx,rx) (ly,ry) (lz,mz)
  (False)   - search3 (k-(mx-lx)-1) (xa,ya,za) (mx+1,rx) (ly,ry) (lz,rz)




-- 
--
Regards,
KC

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


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

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


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


-- 
--
Regards,
KC

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


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

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


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

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

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

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

   - Conal

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





-- 
--
Regards,
KC

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


  1   2   >