On Sat, Aug 14, 2010 at 12:33 PM, Bill Atkins watk...@alum.rpi.edu wrote:
Try this one (http://gist.github.com/524460)
I noticed that Bill's solution doesn't seem to work if the input text
is infinite. I found a different solution, which avoids the use of
reverse, and will work even if the
I am trying to figure out how to use GHC's arrow commands, and I found
some extremely weird behavior.
In GHC's manual, there is a description of arrow commands, which I
don't really understand.
http://www.haskell.org/ghc/docs/latest/html/users_guide/arrow-notation.html#id667303
(Primitive
Hi,
I'm trying to solve the N-queens problem, but with a catch: I want to
generate solutions in a random order.
I know how to solve the N-queens problem; my solver (below) generates all
possible solutions. What I am trying to do is generate solutions in a
random order by somehow randomizing the
Those are some very interesting visual languages, Miguel!
I remember drawing some diagrams when I was teaching myself Haskell, but I
never actually tried to create a formal visual language. Since my
background is in hardware engineering, I would naturally gravitate toward
schematic diagrams. I
On Wed, Mar 24, 2010 at 9:47 PM, Richard O'Keefe o...@cs.otago.ac.nz wrote:
On Mar 25, 2010, at 2:33 PM, Ronald Guida wrote:
... a version of map as text ...
... a diagram ...
The thing that strikes me forcibly is that the diagram
is much bigger than the text. Not only that, but if
I am
On Mon, Mar 22, 2010 at 7:02 PM, Dupont Corentin
corentin.dup...@gmail.com wrote:
Hello, I’m relatively new to Haskell.
I’m wondering if it exist a tool to graphically represent Haskell code.
...
Let’s try to do it on a simple example, as an exercise:
f = Map (+1)
Your graphic for f = map
2008/7/22 Dmitri O.Kondratiev [EMAIL PROTECTED]:
On the side: The more I use Haskell - the more I like it ! It helps me think
about the problem I solve much more clearly then when I use imperative
language.
If I want to replace a substring in a string, then I would search my
string left to
On Thu, 10 July 2008, Marco Túlio Gontijo e Silva wrote:
how do I unbox a existential quantificated data type?
Dan Doel wrote:
elim :: L a - (forall l. l a - r) - r
elim (L e) f = f e
Just one catch: You can't actually write a function 'f' of type
(forall l. l a - r) without knowing
On Thu, Jul 10, 2008 at 4:57 PM, Andre Nathan [EMAIL PROTECTED] wrote:
Hello
I'm trying to create a directed graph using the Data.Graph.Inductive.
The graph is a random graph using the G(n, p) model, that is, each of
the n nodes is linked to every other node with probability p.
So the
Suppose I have a lazy function f :: [Int] - [Int], and I happen to
know that for all n, the n-th element of the output may only depend on
the first (n-1) elements of the input.
I want to print a number from f's output list, and then ask the user
for the next number in f's input list, and then
Emacs Haskell Mode has the following useful feature: when Haskell -
Load File is used to load a file into GHCi from Emacs, Haskell Mode
automatically looks for a *.cabal file in an attempt to find the
project directory.
When Haskell Mode finds the *.cabal file, it fails to check whether it
has
I have added ticket #18 to the Haddock Trac.
http://trac.haskell.org/haddock/wiki
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
I just upgraded to ghc-6.8.3, using a linux binary, and I am having a
problem compiling Haddock. Haddock 2.1.0 and Haddock 2.0.0.0 both
fail to build under ghc-6.8.3, but they both build successfully with
ghc-6.8.2. I don't know if this is a Haddock problem, or a GHC
problem, or perhaps
Bryan Catanzaro wrote:
However, when I ran my random list generator, the interpreter had a stack
overflow. Here's my code again:
---
module Main
where
import IO
import Random
randomList :: Random a = a - a- [IO a]
randomList lbound ubound = randomRIO(lbound,
Monads in Haskell are a topic that I, like most beginners, find
difficult and mind-twisting. Now that I think I understand monads,
they seem to be very simple; I've read that this is a common
experience.
So I wonder, what would it take to help beginners catch on with a
minimum of fuss or
Thank you, apfelmus. That was a wonderful explanation; the debit
method in [1] finally makes sense.
[1]: Chris Okasaki. Purely Function Data Structures.
http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf
___
Haskell-Cafe mailing list
I was looking at the real time queues in [1] and I wanted to see what
would happen if I tried to write one in Haskell. The easy part was
translating the real time queue from [1], p43 into Haskell.
The hard part is testing to see if the rotations really happen what
they should. Basically, I
Don Stewart wrote:
2. Is there any way to systematically search for or detect laziness
leaks?
Profiling, and looking at the Core. Being explicit about the
evaluation strategy you want is a fine idea though.
Albert Y. C. Lai wrote
A true cause of laziness is in accumulating a chain of
Adam Smyczek wrote:
data SampleType = A | B Int | C String | D -- etc.
sampleTypes = [A, B 5, C test] :: [SampleType]
How do I find for example element A in the sampleTypes list?
Here's one way to do it:
filter (\x - case x of A - True; otherwise - False) sampleTypes
== [A]
filter
Two questions:
1. In a Haskell program, if all I want to do is output an image, like
a graph or chart, what is the simplest library to use?
N.B. Simpler := easier to get minimal functionality. I really don't
want to wade through a bunch of boilerplate or climb a steep learning
curve just to be
I wrote:
1. In a Haskell program, if all I want to do is output an image, like
a graph or chart, what is the simplest library to use?
Achim Schneider wrote:
http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Graphics
OK, Chart (the first package under Graphics) is obviously the
It looks like a simple race condition to me. You are using
waitForProcess pid to wait for runInteractiveCommand to finish, but
you don't seem to have anything that waits for createDefFile to
finish.
main :: IO ()
main = do
(file:_) - getArgs
(_, out, _, pid) - runInteractiveCommand $
David Menendez wrote:
To summarize: some applicative functors are commutative, some
applicative functors are monads, and the ones that are both are
commutative monads.
OK, so commutativity is orthogonal to idiom vs monad. Commutativity
depends on whether or not the order of side effects is
I have read that Monad is stronger than Idiom because Monad lets me
use the results of a computation to choose between the side effects of
alternative future computations, while Idiom does not have this
feature. Arrow does not have this feature either.
ArrowChoice has the feature that the sum
I have a few questions about commutative monads and applicative functors.
From what I have read about applicative functors, they are weaker than
monads because with a monad, I can use the results of a computation to
select between alternative future computations and their side effects,
whereas
Thank you for the positive responses. The best kind of feedback is
the kind that makes me have to think, and I've done alot of thinking.
_Regarding monads and interfaces_
Paul Johnson wrote:
1: Your GameState type can itself be made into a monad. Take a look
at the All About Monads tutorial,
I'm playing around with smart constructors, and I have encountered a
weird puzzle.
My goal is to do vector arithmetic. I'm using smart constructors so
that I can store a vector as a list and use the type system to
staticly enforce the length of a vector.
So my first step is to define Peano
I need some help with space and time leaks.
I know of two types of space leak. The first type of leak occurs when
a function uses unnecessary stack or heap space.
GHCi sum [1..10^6]
*** Exception: stack overflow
Apparently, the default definition for sum has a space leak.
I can define my own
Peter Verswyvelen wrote:
I though it was impossible to detect a deadlock (and a black hole is
something like a deadlock no?) *before* it occurred, but in this
case, we're talking about detecting it *when* it occurs, no? And
then raising an error instead of just blocking?
Generally, it's not
Sven Panne wrote:
On Friday 21 September 2007 20:19, Ronald Guida wrote:
John Wicket wrote:
yea, that is probably what I need. Can you post in a
step-by-step way.
Here is a set of instructions for what I had to do to get FreeGLUT
working with GHCi [...].
Oh dear, a long a sad story
Miguel Mitrofanov wrote:
A deadlock happens whenever two (or more) threads are blocked on each
other. Deadlocks can be extremely hard to detect, especially if they
occur intermittently.
Isn't that so much different from garbage collection? Replace
thread with chunk of data, and waits for
John Wicket wrote:
yea, that is probably what I need. Can you post in a step-by-step way.
Here is a set of instructions for what I had to do to get FreeGLUT
working with GHCi.
RANT
Just a little warning: my instructions could be wrong in some places.
Normally, in order to verify my
Oops, one slight omission:
4. Download this custom makefile and put in in the ./src directory.
http://hpaste.org/2841
** Call this file Makefile, with no extension.
5. Download this custom def file and put in in the ./src directory.
http://hpaste.org/2842
** Call this file
John Wicket wrote:
I can take any of these opengl applications or other examples on the
web, but I can't get the application to run on Win32?
They will compile(except for the GLU ones) but when I launch them,
the windows just closes? Is HOpenGL supported well on Win32?
SevenThunders wrote:
OK so check out what really happens with liftM2. Suppose I have an IO
containing an involved matrix computation called s. For simplicity
we might
assume that
s :: IO (Int)
and the Int is an index into an array containing a bunch of matrices in C
land. Assume
SevenThunders wrote:
I have a matrix library written in C and interfaced into Haskell
with a lot of additional Haskell support.
[snip]
Unfortunately if I wrap my matrix references in the IO monad, then
at best computations like S = A + B are themselves IO computations
and thus whenever they
Ronald Guida wrote:
How do I create C-libraries that I can load into GHCi? I am trying to
do some basic FFI, and it's not working.
So, after more searching on the internet and some RTFM, I think I
found my answer, and it seems to work, but I don't know if it's the
right answer to generalize
How do I create C-libraries that I can load into GHCi? I am trying to
do some basic FFI, and it's not working.
Here's the background. I created three files, foo.h, foo.cpp, and
test_foo.lhs. (source code below)
Note: I am using MinGW/Msys under Windows XP.
If I compile foo.cpp and then try
Dan Piponi wrote:
On 9/11/07, Andrew Coppin [EMAIL PROTECTED] wrote:
you can fall down a monad and not be able to escape...
It's not so bad. It's in the nature of monads that after you've fallen
in once, you can never get trapped any deeper.
But you can climb higher...
(Note: Best viewed in
Paul L wrote:
But again, why stuck with GLUT? Now there is at least one alternative,
GLFW (http://glfw.sourceforge.net) a cross-platform framework for
OpenGL applications, for which I recently wrote a Haskell interface,
downloadable at http://www.haskell.org/soe/software1.htm. It's
certainly
On 8/28/07, Ronald Guida wrote:
I'm on a Windows box and I'm looking for a way to talk to a serial
port (for example, RS-232) from Haskell. I couldn't find a library to
do this, so I am wondering how to create one.
I figured out FFI and marshaling, and I got my serial port to work in
Haskell
Update:
I downloaded MinGW and MSYS and tried to install the GLUT library. I
just can't get the thing to work, and I feel like I'm sitting in my
own little section of Hell.
I have tried everything I could think of so far, and it still doesn't work.
Today I tried to sanitize my machine and
Paul L wrote:
I believe it's caused by the different versions of GLUT you have.
On 9/8/07, Ronald Guida [EMAIL PROTECTED] wrote:
[...]
Loading package OpenGL-2.2.1 ... linking ... done.
Loading package GLUT-2.1.1 ... linking ... done.
The above message was after you have installed GLUT
I'm on a Windows box and I'm looking for a way to talk to a serial
port (for example, RS-232) from Haskell. I couldn't find a library to
do this, so I am wondering how to create one.
I have a fairly thorough understanding of how to open and use a serial
port with the Windows API. In
I'm trying to understand lazy evaluation as well. I created an
example for myself and I'm wondering if I've got it right.
let adder n = \x - n + x in (map (adder 12) [1,2,3]) !! 1
So the first thing I did is draw a graph to represent my expression.
(map (adder 12) [1,2,3]) !! 1 =
Ronald Guida wrote:
Given the question What is a Monad, I would have to say A Monad is
a device for sequencing side-effects.
peterv [EMAIL PROTECTED] wrote:
Side-effects is a piece of linguistic cruft played fast-and-loose
by too many people in this game. Sequencing suffers the same
disease
Stefan O'Rear wrote:
On Sat, Aug 11, 2007 at 03:00:04PM -0400, Ronald Guida wrote:
The question remains: What is special about Monad or ArrowApply,
compared to Arrow? or What is more general about Arrow, compared
to Monad or ArrowApply?
If all you have is an Arrow, then you must make up
Tillmann Rendel wrote:
Ronald Guida wrote:
Here's a toy language, described by a regular expression:
0(10)*110
I want to read characters, one at a time, and eventually decide to
Accept or Reject a string.
Let me try to understand my options.
* With a simple Arrow, I can create a fixed
David Menendez wrote:
Be sure to read sigpfe's You could have invented monads! and the
Wadler paper.
http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads-and.html
http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf
Most tutorials try to explain what a monad
Brian Brunswick wrote:
g f ??? g ??? f
application a a-b flip ($) b
monad bind m a a-m b= m b
comonad cobind w a w a-b= w b
arrowarr a b arr b c arr a c
Hi,
I'm pondering, is it possible to define a Set monad analogous to the
List monad?
My thinking is as follows:
* fmap f x would apply f to each element in a set x
* return x would create a singleton set {x}
* join x, where x is a set of sets: x = {x1, x2, ... xn},
would form
Hi,
I am trying to use freeglut with GHCi 6.6.1, and I'm stuck. I
downloaded freeglut 2.4.0 and compiled it. I am on a Windows XP
machine, and I found that freeglut compiled out of the box in MS
Visual Studio.Net 2003.
My difficulty is that GHCi is finding GLUT 2.2.1 and not freeglut.
Hi, again.
I started looking at the Euler problems [1]. I had no trouble with
problems 1 through 10, but I'm stuck on problem 11. I am aware that
the solutions are available ([2]), but I would rather not look just
yet.
In Problem 11, a 20x20 grid of numbers is given, and the problem is to
[Ronald Guida, 07/11/07]
Suppose I have a function f that reads a lazy list, such that f
only consumes as much of the list as it needs to. Laziness allows me
to apply f to an infinite list without creating an infinite loop.
Now I want to connect the console to f, such that the list
Hi Everyone,
A few weeks ago, I started learning Haskell (and functional
programming) on my own from the wealth if information on the internet.
I recently read the paper Why Functional Programming Matters [1] and
it led me to wonder how to input a lazy list.
Suppose I have a function f that
55 matches
Mail list logo