I'm trying to learn how to use randomness in Haskell and it seems very
non-straightforward and complex. I could do a lot of things using 'split'
from System.Random, but apparently it's broken. There is the statistics
package here:
http://hackage.haskell.org/package/statistics
Is this a
On Sat, Oct 10, 2009 at 02:59:37PM -0400, Brad Larsen wrote:
Suppose we implement type-level naturals as so:
data Zero
data Succ a
Then, we can reflect the type-level naturals into a GADT as so (not
sure if ``reflect'' is the right terminology here):
data Nat :: * - * where
Zero ::
i'll try a very non-technical explanation that has worked for me so
far. (is it correct? does it make sense?)
IO and ST are quite similar. the difference is that whereas IO gives
you a concept of time in the world surrounding your code, ST lets you
create a little bubble inside your code in
On 11 Oct 2009, at 15:30, Andrew Coppin wrote:
Iain Barnett wrote:
I'm looking for a library like Perl's Term-Readkey, so that I can
turn on and off the echo for secure password input from a
terminal. Anyone know which library I need to use for this?
The package ansi-terminal allows you
I'm looking at Control.Monad.Random which provides the Rand monad. I would
like to know how to use this for generating multiple infinite series, while
trusting that the implementation never uses split behind the scenes.
(Note: I'm on Windows XP, and there appears to be a bug in getStdGen. It
Hi Bob,
I tried to understand this by applying what you said here to your deep
embedding of a parsing DSL. But I can't figure out how to do that.
What things become the type class T?
greetings,
Sjoerd
On Oct 7, 2009, at 9:18 PM, Robert Atkey wrote:
What is a DSL?
How about this as a
This problem of dynamically transforming grammars and bulding parsers
out of it is addressed in:
@inproceedings{1411296,
author = {Viera, Marcos and Swierstra, S. Doaitse and Lempsink,
Eelco},
title = {Haskell, do you read me?: constructing and composing
efficient top-down parsers at
Does anyone know if it's possible to write the following:
** :: (Applicative m, Applicative n) =
m (n (a-b)) - m (n a) - m (n b)
Clearly, if m and n were monads, it would be trivial.
Rereading the original paper, I didn't see much discussion
about such nested app. functors.
Any help
From: Derek Elkins derek.a.elk...@gmail.com
On Sun, Oct 11, 2009 at 8:55 AM, Iain Barnett iainsp...@gmail.com wrote:
On 11 Oct 2009, at 13:58, John Lato wrote:
For anyone writing introductions to generic programming, take this as
a plea from Haskellers everywhere. If one of the RWH
On Mon, Oct 12, 2009 at 6:22 PM, Kim-Ee Yeoh a.biurvo...@asuhan.com wrote:
Does anyone know if it's possible to write the following:
** :: (Applicative m, Applicative n) =
m (n (a-b)) - m (n a) - m (n b)
Clearly, if m and n were monads, it would be trivial.
Rereading the original paper, I
This looks like what is described in Section 4 to me:
http://www.haskell.org/haskellwiki/Applicative_functor#Applicative_transfomers
- jeremy
On Oct 12, 2009, at 11:22 AM, Kim-Ee Yeoh wrote:
** :: (Applicative m, Applicative n) =
m (n (a-b)) - m (n a) - m (n b)
The first of these works, but not the second. It would seem that the type
cannot change along a = chain, but I may be missing something in the code.
Is the second example illegal? If so, is there a different way to change a
String to an Int along the = chain?
Michael
===
import
On Mon, Oct 12, 2009 at 6:37 PM, michael rice nowg...@yahoo.com wrote:
transform :: IO ()
transform = putStrLn What is your digit string?
getLine
= \str - return ('9':str)
= \str - return (read str :: Int)
= \i - putStrLn $ The number is ++ show i
This
2009/10/12 michael rice nowg...@yahoo.com
The first of these works, but not the second. It would seem that the type
cannot change along a = chain, but I may be missing something in the code.
Is the second example illegal? If so, is there a different way to change a
String to an Int along
That's it: liftA2 (*), so obvious in hindsight.
Mustn't ... code ... when ... drained
Thanks to Jeremy and Josef.
Jeremy Shaw-3 wrote:
This looks like what is described in Section 4 to me:
http://www.haskell.org/haskellwiki/Applicative_functor#Applicative_transfomers
- jeremy
fmap (*) :: m (n (a - b)) - m (n a - n b)
so
f ** x = (fmap (*) f) * x
On Mon, Oct 12, 2009 at 9:22 AM, Kim-Ee Yeoh a.biurvo...@asuhan.com wrote:
Does anyone know if it's possible to write the following:
** :: (Applicative m, Applicative n) =
m (n (a-b)) - m (n a) - m (n b)
Clearly, if
Dumb! I just figured out I was entering the input string in quotes.
So, I suppose the answer to my question is yes, type CAN be changed along a =
chain. I was having trouble doing it in a different problem, created this small
example to illustrate the problem, and then screwed it up putting
I hope you're not building some unneeded rules in your head. There is no
reason to believe there is something to be remembered about whether or not
types can change along a = chain. That chain has nothing special in
Haskell. = is just an operator, much like ++, ! or .
ghci :t (=)
(=) :: (Monad m)
On Mon, 2009-10-12 at 15:49 +0200, Sjoerd Visscher wrote:
Hi Bob,
I tried to understand this by applying what you said here to your deep
embedding of a parsing DSL. But I can't figure out how to do that.
What things become the type class T?
Here's the API version of the grammar DSL:
Is it possible to prove correctness of a functions by testing it? I think the
tests would have to be constructed by inspecting the shape of the function
definition.
--
View this message in context:
http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html
Sent from the
In general? No- If we had an implementation of the `sin` function, how
can testing a finite number of points along it determine
if that implementation is correct for every point?
For specific functions (particularly those with finite domain), it is
possible. If you know the 'correct' output
It is possible for functions with compact domain, not just finite.
2009/10/12 Joe Fredette jfred...@gmail.com:
In general? No- If we had an implementation of the `sin` function, how can
testing a finite number of points along it determine
if that implementation is correct for every point?
For example, it is possible to prove correctness of a function
negatedHead :: [Bool] - Bool by testing it on True:undefined and
False:undefined.
2009/10/12 Eugene Kirpichov ekirpic...@gmail.com:
It is possible for functions with compact domain, not just finite.
2009/10/12 Joe Fredette
Really? How? That sounds very interesting, I've got a fair knowledge
of basic topology, I'd love to see an application
to programming...
On Oct 12, 2009, at 1:55 PM, Eugene Kirpichov wrote:
It is possible for functions with compact domain, not just finite.
2009/10/12 Joe Fredette
Also google seemingly impossible functional programs.
2009/10/12 Eugene Kirpichov ekirpic...@gmail.com:
For example, it is possible to prove correctness of a function
negatedHead :: [Bool] - Bool by testing it on True:undefined and
False:undefined.
2009/10/12 Eugene Kirpichov
Oh- thanks for the example, I suppose you can disregard my other
message.
I suppose this is a bit like short-circuiting. No?
On Oct 12, 2009, at 1:56 PM, Eugene Kirpichov wrote:
For example, it is possible to prove correctness of a function
negatedHead :: [Bool] - Bool by testing it on
On Mon, Oct 12, 2009 at 10:42 AM, muad muad.dib.sp...@gmail.com wrote:
Is it possible to prove correctness of a functions by testing it? I think the
tests would have to be constructed by inspecting the shape of the function
definition.
not True==False
not False==True
Done. Tested :-)
Less
On Mon, Oct 12, 2009 at 12:25 AM, Michael Mossey m...@alumni.caltech.eduwrote:
I'm trying to learn how to use randomness in Haskell and it seems very
non-straightforward and complex. I could do a lot of things using 'split'
from System.Random, but apparently it's broken. There is the
I completely forgot about free theorems! Do you have some links to
resources -- I tried learning about them a while
ago, but couldn't get a grasp on them... Thanks.
/Joe
On Oct 12, 2009, at 2:00 PM, Dan Piponi wrote:
On Mon, Oct 12, 2009 at 10:42 AM, muad muad.dib.sp...@gmail.com
wrote:
On Mon, Oct 12, 2009 at 11:01 AM, Bryan O'Sullivan b...@serpentine.comwrote:
Pseudorandomness seems like one case where it would just be a hell of a lot
simpler to have a global generator--never split the state. Is the ST monad
some way to accomplish this?
Having [...]
Feh, gmail fail.
Joe,
On Mon, Oct 12, 2009 at 11:03 AM, Joe Fredette jfred...@gmail.com wrote:
I completely forgot about free theorems! Do you have some links to resources
-- I tried learning about them a while
ago, but couldn't get a grasp on them... Thanks.
There is Wadler's paper but I do find it tricky:
What do you mean under short-circuiting here, and what is the connection?
The property that allows to deduce global correctness from correctness
on under-defined inputs is just continuity in the topological sense.
2009/10/12 Joe Fredette jfred...@gmail.com:
Oh- thanks for the example, I suppose
I'm making the same mistake repeatedly. In both my mails there are
places where I said (a,b) or (b,a) when I meant (a,a).
--
Dan
On Mon, Oct 12, 2009 at 11:09 AM, Dan Piponi dpip...@gmail.com wrote:
Joe,
On Mon, Oct 12, 2009 at 11:03 AM, Joe Fredette jfred...@gmail.com wrote:
I completely
I mean that, like in the definition of `||`
True || _ = True
False || x = x
If you generalize this to `or`-ing a list of inputs, eg:
foldr (||) False list_of_bools
you can 'short-circuit' the test as soon as you find a 'True' value.
This is actually not the greatest example,
Dan Piponi wrote:
On Mon, Oct 12, 2009 at 10:42 AM, muad muad.dib.sp...@gmail.com wrote:
Is it possible to prove correctness of a functions by testing it?
consider a function of signature
swap :: (a,b) - (b,a)
We don't need to test it at all, it can only do one thing, swap its
Hallo everyone,
the last few weeks I was trying to get used to memoization in haskell. As I
found out in a previous post, memoization in haskell is, due to the graph
reduction strategy used in haskell, almost always implemented by sharing
subexpressions in an expression.
In examples as the
**Edit: formatting was bad**
Hallo everyone,
the last few weeks I was trying to get used to memoization in haskell. As I
found out in a previous post, memoization in haskell is, due to the graph
reduction strategy used in haskell, almost always implemented by sharing
subexpressions in an
Neil Brown wrote:
Dan Piponi wrote:
On Mon, Oct 12, 2009 at 10:42 AM, muad muad.dib.sp...@gmail.com wrote:
Is it possible to prove correctness of a functions by testing it?
consider a function of signature
swap :: (a,b) - (b,a)
We don't need to test it at all, it can only do one
On Mon, Oct 12, 2009 at 11:31 AM, Neil Brown nc...@kent.ac.uk wrote:
swap = undefined
Terminates and does not swap its arguments :-) What do free theorems say
about this, exactly -- do they just implicitly exclude this possibility?
I'm terrible at reasoning about functions with bottoms (ie.
2009/10/12 SimonK77 simonkaltenbac...@googlemail.com:
**Edit: formatting was bad**
Hallo everyone,
the last few weeks I was trying to get used to memoization in haskell. As I
found out in a previous post, memoization in haskell is, due to the graph
reduction strategy used in haskell,
minh thu not...@gmail.com writes:
ghci :t (=)
(=) :: (Monad m) = m a - (a - m b) - m b
This says that, you provide an a and you get a b. Nothing says the a and b
have to be the same upon successive uses.
(But note that the monad 'm' has to be the same all the way. You can't
switch from,
Joe Fredette wrote:
Really? How? That sounds very interesting, I've got a fair knowledge
of basic topology, I'd love to see an application
to programming...
Compactness is one of the most powerful concepts in mathematics, because on
the one hand it makes it possible to reduce many infinite
2009/10/12 Ketil Malde ke...@malde.org:
minh thu not...@gmail.com writes:
ghci :t (=)
(=) :: (Monad m) = m a - (a - m b) - m b
This says that, you provide an a and you get a b. Nothing says the a and b
have to be the same upon successive uses.
(But note that the monad 'm' has to be the
That has got to be the single awesomest thing I have ever seen ever...
The first time I tried to read through the Seemingly Impossible
Functional Programs post, I understood none of it. Now it seems
obviously.
I Love Math...
Thanks for the explanation!
/Joe
On Oct 12, 2009, at 3:22 PM,
Neil Brown nc...@kent.ac.uk writes:
swap :: (a,b) - (b,a)
We don't need to test it at all, it can only do one thing, swap its
arguments. (Assuming it terminates.)
swap = undefined
Terminates and does not swap its arguments :-)
I think this counts as non-termination, and that for semantic
Could that nice precise formulation simply be Scott continuity, which in
turn preserves compactness through composition and under application?
Dan Piponi wrote:
On Mon, Oct 12, 2009 at 11:31 AM, Neil Brown nc...@kent.ac.uk wrote:
swap = undefined
Terminates and does not swap its arguments
On Mon, Oct 12, 2009 at 11:52:30AM -0700, SimonK77 wrote:
**Edit: formatting was bad**
Hallo everyone,
the last few weeks I was trying to get used to memoization in haskell. As I
found out in a previous post, memoization in haskell is, due to the graph
reduction strategy used in
Am Montag 12 Oktober 2009 21:09:38 schrieb minh thu:
2009/10/12 SimonK77 simonkaltenbac...@googlemail.com:
**Edit: formatting was bad**
Hallo everyone,
the last few weeks I was trying to get used to memoization in haskell. As
I found out in a previous post, memoization in haskell is,
On Mon, Oct 12, 2009 at 1:08 AM, Felipe Lessa felipe.le...@gmail.comwrote:
On Mon, Oct 12, 2009 at 12:42:16AM +0200, Peter Verswyvelen wrote:
btw I always find it amusing to play with interact and lazy IO:
I always find it frightening to play with lazy IO :).
yes, I guess that's why I like
Joe Fredette wrote:
That has got to be the single awesomest thing I have ever seen ever...
I was dumbfounded, too, when I first read about this.
BTW, and completely off-topic: if you like this, you might have fun too with
Conor McBride's discovery that data types can be differentiated, and the
S. Doaitse Swierstra wrote:
This problem of dynamically transforming grammars and bulding parsers
out of it is addressed in:
@inproceedings{1411296,
author = {Viera, Marcos and Swierstra, S. Doaitse and Lempsink,
Eelco},
title = {Haskell, do you read me?: constructing and composing
I read about differentiating and differences for types, that was
awesome, but when I read the seemingly-impossible post the first time,
I didn't have enough background in topology to understand what was
going on. Differentiating types is usually how I introduce the power
of haskell's type
I'm trying to host a cgi I've written. It uses Database.HDBC,
Database.HDBC.MySQL, Network.CGI, and Text.XHtml.Transitional
Here is the command I'm using to compile
ghc --make -optl-static -optl-pthread -static -o test.cgi
-package cgi -package xhtml -package HDBC-mysql -package HDBC -optl
-lz
I can't get the following to work in Leksah - but it works OK in GHC.
Can anyone spot the error?
I wondered if it was becasue the libraries loaded are different - but
I'm just a Haskell beginner ...
I have:
myGroupBy :: Int→ [a]→ [[a]]
myGroupBy = takeWhile not . null . (unfoldr (Just .
Am Dienstag 13 Oktober 2009 01:03:24 schrieb b1g3ar5:
I can't get the following to work in Leksah - but it works OK in GHC.
Can anyone spot the error?
I wondered if it was becasue the libraries loaded are different - but
I'm just a Haskell beginner ...
I have:
myGroupBy :: Int→ [a]→
On Sun, Oct 11, 2009 at 06:29:58PM -0400, Brandon S. Allbery KF8NH wrote:
On Oct 11, 2009, at 18:00 , Ben Franksen wrote:
Ben Franksen wrote:
Ben Franksen wrote:
Next thing I'll try is to transform such a grammar into an actual
parser...
Which I also managed to get working.
First, before
Do you know any category theory? What helped me finally grok free
theorems is that in the simplest cases, the free theorem for a
polymorphic function is just a naturality condition. For example, the
free theorem for
flatten :: Tree a - [a]
is precisely the statement that flatten is a natural
Hi all,
I've just received the following error message:
headers.hs:6:7:
Could not find module `Control.Monad.Identity':
it was found in multiple packages: transformers-0.1.4.0 mtl-1.1.0.2
I'm trying to use the Iteratee module which depends on Transformers
but I use MTL in other
ghc-pkg hide transformers
On Oct 12, 2009, at 5:46 PM, Erik de Castro Lopo wrote:
Hi all,
I've just received the following error message:
headers.hs:6:7:
Could not find module `Control.Monad.Identity':
it was found in multiple packages: transformers-0.1.4.0
mtl-1.1.0.2
I'm
Erik de Castro Lopo wrote:
Gregory Crosswhite wrote:
ghc-pkg hide transformers
Here's an example. CGI uses MTL, Iteratee uses Transformers.
So, how do you use CGI and Iteratee in the same program?
CGI is just one of many examples. Text.Regex, Network.HTTP,
Database.HDBS.Sqlite,
Sadly not enough, I understand the basics, but the whole proof =
this diagram commutes thing still seems like
voodoo to me. There is a section coming up in my Topology ISP that
will be on CT. So I hope that I will be able to
gain some purchase on the subject, at least enough to build up a
Ugh, I'm not as sure about that... it took me long enough just to
figure out ghc-pkg hide transformers! :-)
Are running into problems because you need to refer to both packages
(e.g., mtl and transformers) within your code, or because you are
using packages that refer to each? Because
I fiddled with my previous idea -- the NatTrans class -- a bit, the
results
are here[1], I don't know enough really to know if I got the NT law
right, or
even if the class defn is right.
Any thoughts? Am I doing this right/wrong/inbetween? Is there any use
for a class
like this? I listed a
On Mon, Oct 12, 2009 at 8:15 PM, Joe Fredette jfred...@gmail.com wrote:
Sadly not enough, I understand the basics, but the whole proof = this
diagram commutes thing still seems like
voodoo to me. There is a section coming up in my Topology ISP that will be
on CT. So I hope that I will be able
Gregory Crosswhite wrote:
Are running into problems because you need to refer to both packages
(e.g., mtl and transformers) within your code, or because you are
using packages that refer to each?
The later. Iteratee uses Transformers and just about everything else
I want to use uses MTL.
a brain fart?
Hi, cafe, I've been playing a little bit with a small command
processor, and I decided it'd be nice to allow the user to not have to
enter a complete command, but to recognize a unique prefix of it. So I
started with the list of allowed commands, used filter and isPrefixOf,
and was
I'm having some trouble with QuickCheck2 and Control.Applicative.
Specifically, I have the following functions (slightly simplified):
copyVector :: IOVector - Vector - IO ()
freezeVector :: IOVector - IO (Vector)
I have a test, part of which looks like
monadicIO $ do
run $
On Oct 12, 2009, at 22:28 , Uwe Hollerbach wrote:
parsePrefixOf n str =
string (take n str) opts (drop n str) return str
where opts [] = return ()
opts (c:cs) = optional (char c opts cs)
Seems to me this will succeed as soon as it possibly can...
myTest = myPrefixOf 1 banana
On 10/12/09, Derek Elkins derek.a.elk...@gmail.com wrote:
On Mon, Oct 12, 2009 at 9:28 PM, Uwe Hollerbach uhollerb...@gmail.com
wrote:
a brain fart?
Hi, cafe, I've been playing a little bit with a small command
processor, and I decided it'd be nice to allow the user to not have to
enter a
Something that I have been wondering for a while is: why are there
*still* two monad transformer libraries with seemingly identical
functionality, especially given that they have conflicting
namespaces? It creates stupid problems like the one that Erik
encountered and had to work around.
Reid Barton:
On Sat, Oct 10, 2009 at 02:59:37PM -0400, Brad Larsen wrote:
Suppose we implement type-level naturals as so:
data Zero
data Succ a
Then, we can reflect the type-level naturals into a GADT as so (not
sure if ``reflect'' is the right terminology here):
data Nat :: * - * where
Lajos Nagy:
I understand that one of the original motivations for introducing
associated types to Haskell was the survey of support for generic
programming done by Garcia et al. where they compared the
implementation of the Boost Graph Library in various languages (C++,
Java, Haskell, ML,
72 matches
Mail list logo