uj supplied this:
About the discussion
putStrLn (readLn + (5 :: Int))..
I'll write it as the following line,
importing Control.Applicative
main = (+) readLn (return 3)
They look almost exactly same in my eyes..
On Fri, 21 Jan 2011 11:01:36 -0800, you wrote:
Interesting little paper,
Of course Banks/Financial Firms/Investment Banks want software that is
correct, secure, and logs transactions.
Aspects are great for cross-cutting concerns like security and
logging; as in AspectJ.
For correctness, functional programming has that.
With monads its easy to add logging and
Doesn't mutable state have to be held in a monad?
If you want mutable like behaviour without a monad, you may want a
tree or some other data structure.
On Wed, 7 Jul 2010 17:08:48 +0300, you wrote:
Hi,
A friend of mine wanted to do some Cellular Automata experiments in
Haskell and was asking
Is there good place to post Haskell alorithms/data structures that
follow Steven Skiena's book on algorithm design and also Haskell code
snippets that follow some of Knuth's books?
These code snippets don't seem to fit with Hackage.
Is there a Hatorial?
--
Regards,
Casey
But as a
starting point, and especially to shake up preconceived notions,
it still helps to compress common prejudices this way.
Many people think they are thinking when they are merely rearranging
their prejudices. William James?
:)
--
Regards,
Casey
I remember quite a few months ago, someone gave a presentation on
Haskell and he admitted that so far all he had used it for were shell
scripts. He said that his Haskell shell scripts ran faster than his
shell scripts written in ?
So all he had used so far, was just the imperative part of
I have both books.
The challenge is to get something linked from the The Stony Brook
Algorithm Repository (http://www.cs.sunysb.edu/~algorith/) to a
Haskell algorithms/data structures page to promote Haskell.
For those who would not pick up a book (nor web page) with Haskell or
functional in the
Hi:
Steven S. Skiena of The Algorithm Design Manual, Second Edition,
2008 has sent me a message that if there is a Haskell page of
algorithms he will link to it.
So, is there such a page and/or is there some collection(s) of
algorithms and data structures some where that I can massage into the
This is an effect with any language that offers a very high degree of
abstraction.
I think this is an example of the Haskell effect (more typically
seen on #haskell), which can be categorised as follows:
1) Someone asks a (usually rather simple) question.
2) People discuss this and provide
Apparently, Erlang does not have a static type system, since with hot
code loading, this is intrinsically difficult.
Erlang Programming, Francesco Cesarini Simon Thompson, June 2009,
O'Reilly, page 31.
If Haskell allows hot code loading, would this throw a wrench into the
static type system?
You may want to use a mutable array.
The performance may suffer from the memory allocation for the list. I
wonder if it's possible to make Haskell implementation work faster
without changing the algorithm (there's are actually a few tricks to
make it work faster, but neither implementations have
This sounds like homework.
Think in abstract terms what you want to accomplish.
Start with the simplest case first, usually the base case.
On Fri, 12 Mar 2010 14:02:02 +0800, you wrote:
Hi,
For example, I have this:
list1 = [a, b, c]
list2 = [d, e, f]
list3 = [g, h, i]
Now I want:
[ [(a,
On Tue, 23 Feb 2010 08:30:18 -0300, you wrote:
Hi folks,
While solving a puzzle, I was posed the problem of finding if there was no
duplicates on a list.
Must it be a list data structure(DS) or list ADT?
Mergesort can be parallelized.
Best regards,
Rafael
--
Regards,
Casey
On Tue, 23 Feb 2010 08:30:18 -0300, you wrote:
Hi folks,
While solving a puzzle, I was posed the problem of finding if there was no
duplicates on a list.
Must it be a list data structure(DS) or list ADT?
Mergesort can be parallelized.
Best regards,
Rafael
If space is at a premium you
On Tue, 9 Feb 2010 21:56:49 +, you wrote:
Monads are not commutative. A structure that would tell the compiler
that it's commutative, would give it more leeway for optimization (and
parallel execution).
Thank you.
Not commutative was the phrase I was looking for.
--
Regards,
Casey
You could also implement stacks with mutable data structures, e.g.
STArray, etc.
What do you want to use a stack ADT for?
Usually stacks are discussed for pedagogical purposes but usually
recursion is used if you need a stack like operation.
--
Regards,
Casey
On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote:
Can't find a Stack datatype on Hoogle? Where should I look?
Michael
From Algorithms: a functional programming approach
Second edition
Fethi Rabhi
Guy Lapalme
data Stack a= EmptyStk
On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote:
Can't find a Stack datatype on Hoogle? Where should I look?
Michael
From Algorithms: a functional programming approach
Second edition
Fethi Rabhi
Guy Lapalme
To be more complete.
module Stack(Stack,push,pop,top,emptyStack,stackEmpty)
I have not read all/most of the replies.
What material benefit does Haskell derive from being a pure functional
language as opposed to an impure one? Please provide examples as I require
instruction.
A pure functional lanugage allows lazy evaluation, which adds another
tool to your modularity
Are there major inefficiencies in Haskell compared to OCaml?
If so, can something be done about them?
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Please check out Paul Hudak's page.
http://cs-www.cs.yale.edu/homes/hudak-paul/
On Tue, 01 Dec 2009 17:01:29 -0800, you wrote:
Perhaps someone could either (1) help me do what I'm trying to do, or (2) show
me a better way.
I have a problem that is very state-ful and I keep thinking of it as
I would suspect that the IO Monad is to unsafe, maybe a more stringent
monad would be more appropriate.
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
You can pattern match on the right hand side of '|' in a list
comprehension, since a list comprehension is just the list monad.
Just changed a few things.
Hopefully this answers the OP's question and any interested others.
add :: Int - Int - Int
add x y = x + y
-- a list of partially applied
Will the following do what you wish?
add :: Int - Int - Int
add x y = x + y
addends = [3,5,7,3,5,8]::[Int]
add3s :: [Int] - [Int - Int]
add3s addends = map add (filter (3==) addends)
k3 :: [Int]
k3 = map (\ f - f 10 ) (add3s addends)
--
Regards,
Casey
Will the following do what you wish?
add :: Int - Int - Int
add x y = x + y
addends = [3,5,7,3,5,8]::[Int]
-- P for predicate
addPs :: (Int - Bool) - [Int] - [Int - Int]
addPs predicate addends = map add (filter predicate addends)
kP :: [Int]
kP = map (\ f - f 10 ) (addPs (3==) addends)
--
It sounds as if you want to carry some state around for each partially
applied function, I think that's in monad territory.
A cardinal rule of functional programming is to create new data,
whenever possible.
--
Regards,
Casey
___
Haskell-Cafe mailing
You can pattern match on the right hand side of '|' in a list
comprehension, since a list comprehension is just the list monad.
add :: Int - Int - Int
add x y = x + y
-- a list of partially applied functions
adds = [add 3, add 5, add 7, add 3, add 5, add 8]
-- an example usage of the list
kP
An idea to reduce memeory latency, is to have a complex dual/quad/etc.
core CPU surrounded by four or more simpler CPUs.
The simpler CPUs have a simpler instruction set and do less context
switching.
So any operations (e.g. folding, filtering) that reduce the size of a
larger data structure and
If you haven't bought any of Knuth's fascicles yet, this is definitely
the one to get.
The Art of Computer Programming: Volume 4
Bitwise Tricks Techniques
Binary Decision Diagrams
Fascicle 1
Donald E. Knuth
2009
Describes basic broadword operations and an important class of data
structures
, Casey Hawthorne cas...@istar.ca wrote:
If you haven't bought any of Knuth's fascicles yet, this is definitely
the one to get.
The Art of Computer Programming: Volume 4
Bitwise Tricks Techniques
Binary Decision Diagrams
Fascicle 1
Donald E. Knuth
2009
Describes basic broadword operations
What is this big project about?
Why not use www.sourceforge.net?
On Mon, 16 Nov 2009 21:15:44 +0100, you wrote:
Hi all,
I'm stuck with a problem where I need serious help from other haskellers,
in particular those that participate here on this list. It's a rather big
project and I will
On Mon, 16 Nov 2009 23:43:49 +0300, you wrote:
Hello Casey,
Monday, November 16, 2009, 11:30:51 PM, you wrote:
Why not use www.sourceforge.net?
i strongly recommend http://code.google.com or http://codeplex.com
SF is slow and olf-fashioned
Just because a Scandinavian started it, doesn't mean
I'm also missing examples of library function and Hackage usage.
Where does one put up code on the Haskell Wiki?
:)
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Where is a good place to place code like this, so if I may be so bold,
people can learn from it?
{- Author Modifications:Casey Hawthorne
Author Original: Jeff Newbern
Maintainer: Casey Hawthorne cas...@istar.ca
Maintainer?: Jeff Newbern jnewb...@nomaware.com
Time-stamp
Hi Bulat:
I believe Jeff's original idea was to show an example of a monad
transformer stack and ASCII art output.
On Sat, 14 Nov 2009 21:42:01 +0300, you wrote:
Hello Casey,
Saturday, November 14, 2009, 9:15:51 PM, you wrote:
Where is a good place to place code like this, so if I may be so
Sorry, I forgot to ask an important question.
Is the table stored
in a dense format as in complete rows and complete columns
or
in a sparse table format?
The question is more about algorithm than Haskell. But I am going to code in
Haskell which I am still learning.
Suppose I have a large
Thank you to all who replied, very instructive.
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
To: Casey Hawthorne cas...@istar.ca
Subject: Re: [Haskell-cafe] looking for a good algorithm
From: Casey Hawthorne cas...@istar.ca
Date: Thu, 12 Nov 2009 11:14:02 -0800
On third thought, convert the table to a 2D array of bits (or a 1D
array of bits mapped to a 2D coordinate system).
The bit
Why can I run (runghc) some Haskell scripts but I cannot seem to
compile them?
e.g. http://www.haskell.org/all_about_monads/examples/example25.hs
I've changed the import listing to the following:
import IO
import System
import Monad
import Data.Maybe
import Data.List
import Data.Char (toLower)
Why can I run (runghc) some Haskell scripts but I cannot seem to
compile them?
e.g. http://www.haskell.org/all_about_monads/examples/example25.hs
I've changed the import listing to the following:
import IO
import System
import Monad
import Data.Maybe
import Data.List
import Data.Char (toLower)
Shazam!
Thank you!
On Thu, 12 Nov 2009 15:13:47 -0500, you wrote:
Did you try ghc --make?
On Thu, Nov 12, 2009 at 3:12 PM, Casey Hawthorne cas...@istar.ca wrote:
Why can I run (runghc) some Haskell scripts but I cannot seem to
compile them?
e.g. http://www.haskell.org/all_about_monads
Why in a pattern match like
score (1 3) = 7
can I not have
sizeMax = 3
score (1 sizeMax) = 7
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
So, as I understand it, you have a very large sparse table, thousands
of rows and hundreds of columns, of which each cell within a column of
type String, Int, or Double can contain one of those types or nothing.
Then you to want to shuffle the rows to maximize the number of columns
whose first
How about these type signatures.
import Data.List
poly1 = [(0,1),(5,0),(3,4)]::[(Double,Double)]
areaPoly :: [(Double,Double)] - Double
areaPolyCalc :: (Double,(Double,Double)) - (Double,Double) -
(Double,(Double,Double))
Spoiler Alert! -- Functions Below!
How about these BETTER type signatures.
-- Area of a Polygon
import Data.List
type X = Double
type Y = Double
type Area = Double
poly1 = [(0,1),(5,0),(3,4)]::[(X,Y)]
areaPoly :: [(X,Y)] - Area
areaPolyCalc :: (Area,(X,Y)) - (X,Y) - (Area,(X,Y))
Spoiler Alert! -- Functions
Sorry, I forgot to add that if the polygon is very far from the
origin, you may have overflow or increased round off error; it is
better to translate the polygon back to the origin, before doing the
area calculation.
How about these BETTER type signatures.
-- Area of a Polygon
import
the calculation, without
evaluating more points.
--- On Sun, 11/8/09, Casey Hawthorne cas...@istar.ca wrote:
From: Casey Hawthorne cas...@istar.ca
Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl
To: haskell-cafe@haskell.org
Date: Sunday, November 8, 2009, 5:44 PM
Sorry, I forgot to add
I don't know if this is homework.
I suppose what you mean is the following: I'm trying to replace an
element in an n-ary tree and display the completed tree.
A more precise specification might help.
- is the tree ordered
- are all the elements in the leaves (not internal nodes)
- is the location
Is there a way to embed a Haskell interpreter/compiler in a browser.
I think this would be a safer language than JavaScript.
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
On Wed, 30 Sep 2009 21:24:11 +0200, you wrote:
I?m a physicist, so I think they would be attracted by something like
Haskell: high level physics modelling at Fortran speeds
Haskell: mathematics beyond numerical calculus
And,
easier to make use of multi-core machines than threaded Fortran.
I read somewhere that for 90% of a wide class of computing problems,
you only need 10% of the source code in Haskell, that you would in an
imperative language.
If this is true, it needs to be pushed.
And if by changing a few lines of source code one can develop a whole
family of similar
On Tue, 29 Sep 2009 18:19:08 -0700, you wrote:
On Tue, Sep 29, 2009 at 5:24 PM, Casey Hawthorne cas...@istar.ca wrote:
I read somewhere that for 90% of a wide class of computing problems,
you only need 10% of the source code in Haskell, that you would in an
imperative language
If you do a student's homework, you are cheating that student out of
an education.
He/She may realize that t late in the future.
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
I think a language needs the following to exist:
- a community
- good library
- a package manager
Thoughts?
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
On Tue, 29 Sep 2009 12:25:30 +1000, you wrote:
I think one must distinguish what it means for a language to exist and
be practical. Counter-example: Java fails catastrophically at all
three and it most certainly exists; boy do I know it.
QOTM!
Casey Hawthorne wrote:
I think a language needs
On Mon, 28 Sep 2009 21:50:14 -0500, you wrote:
Good libraries are not enough for a language to go beyond mere existence.
There must exist good documents, i.e., good tutorials, good books, and good
explanations and examples in the libraries, etc, that are easy for people to
learn and use. In my
On Mon, 28 Sep 2009 21:50:14 -0500, you wrote:
Good libraries are not enough for a language to go beyond mere existence.
There must exist good documents, i.e., good tutorials, good books, and good
explanations and examples in the libraries, etc, that are easy for people to
learn and use. In my
I think a 16-bit float type would require compiler revisions as
opposed to doing something within the present type classes.
This is similar to how Java would benefit from an unsigned byte
primitive type for processing images, etc., whereas Haskell already
has Word8.
--
Regards,
Casey
On Mon, 28 Sep 2009 12:06:47 +1300, you wrote:
On Sep 28, 2009, at 9:40 AM, Olex P wrote:
Hi,
Yes, I mean sizeOf 2. It's useful not only on GPUs but also in
normal software. Think of huge data sets in computer graphics
(particle clouds, volumetric data, images etc.) Some data (normals,
How does one delare a 2D STUArray in Haskell?
I see the following from a diffusion program segment:
module Diffusion where
import Data.Array
import Data.List (sortBy)
type VFieldElem = Float
type VField = Array (Int,Int) VFieldElem
snip
zeros = listArray ((1,1),(imax,jmax)) (repeat 0)
Well that makes sense, but for a learner, how is he/she supposed to
know that 'i' could be '(i,i)' or for that matter a tuple of n of
those i's?
STUArray s i e
Could you also have a tuple of states?
Obviosly, 'e' could be a tuple, for instance (Int,Char)
--
Regards,
Casey
On Fri, 25 Sep 2009 23:25:21 +0200, you wrote:
On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish jvran...@gmail.com wrote:
Supposedly OCaml has an OO feature that does this but I haven't tried it
out.
Indeed, OCaml has stuctural polymorphism, it's a wonderful feature.
*# let f myobj = myobj#foo
On Fri, 25 Sep 2009 23:25:21 +0200, you wrote:
On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish jvran...@gmail.com wrote:
Supposedly OCaml has an OO feature that does this but I haven't tried it
out.
Indeed, OCaml has stuctural polymorphism, it's a wonderful feature.
*# let f myobj = myobj#foo
Posting small packages like that on Hackage is a good way for others
to learn Haskell.
Is a record kept of suggested changes on Hackage?
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Do I have this right? Remembering Memoization!
For some applications, a lot of state does not to be saved, since
initialization functions can be called early, and these functions
will remember - (memoize) their results when called again, because
of lazy evaluation?
--
Regards,
Casey
The other morning, someone was telling me they had converted most of
their VB financial/stock market code to F#.
Whereas VB only used one core, the F# code used all four cores.
In one software developers meeting, someone was saying that since
database work is mostly all state, he didn't see the
The other morning, someone was telling me they had converted most of
their VB financial/stock market code to F#.
Whereas VB only used one core, the F# code used all four cores.
In one software developers meeting, someone was saying that since
database work is mostly all state, he didn't see the
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Since the JVM doesn't seem to support tail call optimization, I
suppose one could could directly manipulate the bytecodes generated by
jhc to do TCO.
One challenge would be the garbage collector, since Haskell and Java
have very different working sets of what is still being used.
--
Regards,
On Wed, 17 Jun 2009 00:45:56 -0400, you wrote:
And here's a version along similar lines that avoids (++) for greater
sharing and efficiency:
let sss = [] : [ [ c:s | c - ['a'..'z'], s - ss ] | ss - sss ]
in concat (tail sss)
Sheer genius!
I just inverted it since I like to see the main
When folding is there a way to pick out the last point being
processed?
The first point can easily be picked out with (x:xs) but last xs
crawls down the list.
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
The Q Programming Language can do symbolic manipulation -- Haskell?
The Q Programming Language can do the following:
sqr X = X*X
==sqr 5
25
==sqr (X+1)
(X+1)*(X+1)
Can Haskell do symbolic manipulation?
Or are term-rewriting and the lambda calculus sufficiently far enough
apart concepts?
--
72 matches
Mail list logo