OK, I get the reference to currying now. A function of 2 variables can be seen
as a function of one that returns another function of one. So a function of
one variable can be seen as a function of no variables that returns a function
of one. Very nice.
- Original Message
From: Tim C
Hugh Perkins wrote:
> What makes a callback different from any other kind of function?
Well... what about inside monads? Does this break purity??? Does this
require adding IO to the monad if the callback function does IO?
As I'm writing this I kindof have this sense inside me that this is
On 7/2/07, Gregory Propf <[EMAIL PROTECTED]> wrote:
This was a bit baffling too. It appears that there's an implied argument to
runTick. This also works and makes it more explicit. I suppose the compiler
just works out that the only place to put the 'n' is after tick.
runTick :: Int -> (
This was a bit baffling too. It appears that there's an implied argument to
runTick. This also works and makes it more explicit. I suppose the compiler
just works out that the only place to put the 'n' is after tick.
runTick :: Int -> (String,Int)
runTick n = runState tick n
- Original M
Gregory Propf wrote:
| [...] For example, am I to assume that I need to
| create my own instance of State and then define get and put for it?
No, there is a 'State s' monad provided (for arbitrary state type 's'),
which implements the 'get' and 'put' methods. In other words, 'State s' is
an insta
On 7/2/07, Hugh Perkins <[EMAIL PROTECTED]> wrote:
Well... what about inside monads? Does this break purity??? Does this
require adding IO to the monad if the callback function does IO?
Check out the documentation for the HOpenGL callbacks here:
http://www.haskell.org/HOpenGL/documentation/G
On Jul 2, 2007, at 18:40 , Neil Mitchell wrote:
SystemLogging.LogInfo("Did Something");
SystemLogging.LogInfo("x is " + x );
How can we do something similar in Haskell?
See trace: http://www.haskell.org/hoogle/?q=trace
In addition, you could use the Writer monad to collect log
informatio
On 7/2/07, Hugh Perkins <[EMAIL PROTECTED]> wrote:
Anyway, so the question is: how do we write callback functions in
FP/Haskell? Can someone provide a simple, but functional example?
What makes a callback different from any other kind of function? In
Haskell, as in other functional programmin
http://cvs.haskell.org/cgi-bin
/cvsweb.cgi/fptools/libraries/GLUT/examples/RedBook/
Ok, I'll take a look
What makes a callback different from any other kind of function?
Well... what about inside monads? Does this break purity??? Does this
require adding IO to the monad if the callback f
"Hugh Perkins" <[EMAIL PROTECTED]> writes:
(snip)
>> Maybe, with System.IO,
>
> Fine in main :-) Less good in a 100,000 line application.
Oh, sorry, I thought your point had been about making sure the operation
was done before the "did something" line got printed. (-:
-- Mark
___
On 7/3/07, Neil Mitchell <[EMAIL PROTECTED]> wrote:
See trace: http://www.haskell.org/hoogle/?q=trace
I'll check that out. Thanks.
Maybe, with System.IO,
Fine in main :-) Less good in a 100,000 line application.
___
Haskell-Cafe mailing list
Ha
Graham Hutton has some great tutorials on parsing. Check out the "Are
parsers monodic?" thread (not exact name) for a good reference.
There's also a good tutorial at http://www.cs.nott.ac.uk/~gmh/book.html In
Section "Slides", click on "8 Functional parsers", but you may just want to
start from
"Hugh Perkins" <[EMAIL PROTECTED]> writes:
> SystemLogging.LogInfo("About to do something...");
> DoSomething();
> SystemLogging.LogInfo("Did Something");
> SystemLogging.LogInfo("x is " + x );
>
> How can we do something similar in Haskell?
Maybe, with System.IO,
main =
do log <- openFile "
Hi
SystemLogging.LogInfo("Did Something");
SystemLogging.LogInfo("x is " + x );
How can we do something similar in Haskell?
See trace: http://www.haskell.org/hoogle/?q=trace
Thanks
Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http:/
I hadn't seen that before, thanks. My code wouldn't be that useful as it
depends on some of my datatypes. I don't know some basic things here since I'm
so new to Haskell. For example, am I to assume that I need to create my own
instance of State and then define get and put for it? Some of th
On Tue, Jul 03, 2007 at 12:26:47AM +0200, Hugh Perkins wrote:
> This sounds something like using a continuation function.
>
> In imperative languages, we might have something like:
>
> class MyDisplayForm
> {
> void ButtonGo_Press()
> {
> Processor.Go( new CallbackDelegate( this.SetStat
This sounds something like using a continuation function.
In imperative languages, we might have something like:
class MyDisplayForm
{
void ButtonGo_Press()
{
Processor.Go( new CallbackDelegate( this.SetStatus ) );
}
public void SetStatus( string message )
{
StatusLbl.Text
In imperative languages we can do this type of thing:
SystemLogging.LogInfo("About to do something...");
DoSomething();
SystemLogging.LogInfo("Did Something");
SystemLogging.LogInfo("x is " + x );
How can we do something similar in Haskell?
___
Haskell
vim: set ft=lhaskell:
On Mon, Jul 02, 2007 at 02:25:57PM -0700, Gregory Propf wrote:
| As a programming exercise I'm trying to use the State monad to create
| a simple parser. It's for a very simple assembly language for a
| simple virtual machine. The state is a string of instructions. I
| wan
On Monday 02 July 2007, Andrew Coppin wrote:
> What were monads like before they became a Haskell language construct?
>
> Is Haskell's idea of a "monad" actually anywhere close to the original
> mathematical formalism?
>
> Just being randomly curiose...
Curiosity can be a dangerous thing . . .
Sh
Gregory Propf wrote:
> As a programming exercise I'm trying to use the State monad to create a
> simple parser. It's for a very simple assembly language for a simple
> virtual machine. The state is a string of instructions. I want to be
> able to call something like getNextInstruction to pull o
Gregory Propf wrote:
> Right, I read more about it and found this out. The 'main' function is
> apparently magical at runtime and allows you to break the with pure
> functionality just once but since it can call other functions this allows
> for useful programs to be written.
There is more than
As a programming exercise I'm trying to use the State monad to create a simple
parser. It's for a very simple assembly language for a simple virtual machine.
The state is a string of instructions. I want to be able to call something
like getNextInstruction to pull out the next instruction and
Right, I read more about it and found this out. The 'main' function is
apparently magical at runtime and allows you to break the with pure
functionality just once but since it can call other functions this allows for
useful programs to be written.
- Original Message
From: Jules Bean <
Dan Piponi wrote:
On 7/2/07, Andrew Coppin <[EMAIL PROTECTED]> wrote:
What were monads like before they became a Haskell language construct?
Is Haskell's idea of a "monad" actually anywhere close to the original
mathematical formalism?
It's as close to a mathematician's notion of a monad as H
On 7/2/07, Andrew Coppin <[EMAIL PROTECTED]> wrote:
What were monads like before they became a Haskell language construct?
Is Haskell's idea of a "monad" actually anywhere close to the original
mathematical formalism?
It's as close to a mathematician's notion of a monad as Haskell's
types and
lol small world :-)
On 7/2/07, Philip Armstrong <[EMAIL PROTECTED]> wrote:
On Mon, Jul 02, 2007 at 12:23:36AM +0200, Hugh Perkins wrote:
> Clll :-) Thanks for the link.
>
> Er are you the Philip Armstrong I was at college with
Shhh. Don't tell everyone or they'll all want
What were monads like before they became a Haskell language construct?
Is Haskell's idea of a "monad" actually anywhere close to the original
mathematical formalism?
Just being randomly curiose...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.o
poop wrote:
>
> So I'm working my way thorough haskell, doing some programming problems,
> and I have this one so far:
>
Hi, I haven't spotted the problem in your code but there's an alternative
solution to Euler Problem 14 on the wiki:
http://www.haskell.org/haskellwiki/Euler_problems/11_to_20
On Monday 02 July 2007, apfelmus wrote:
> apfelmus wrote:
> > class DiMonad m where
> > returnR :: a -> m e a
> > bindR :: m e a -> (a -> m e b) -> m e b
> >
> > returnL :: e -> m e a
> > bindL :: m e a -> (e -> m e' a) -> m e' a
> >
> > type TwoCont e a = (e -> R) -> (a ->
apfelmus wrote:
> class DiMonad m where
> returnR :: a -> m e a
> bindR :: m e a -> (a -> m e b) -> m e b
>
> returnL :: e -> m e a
> bindL :: m e a -> (e -> m e' a) -> m e' a
>
> type TwoCont e a = (e -> R) -> (a -> R) -> R
>
> A final question remains: does the dimonad a
class Monad m => MonadError e m | m -> e where
throwError :: e -> m a
catchError :: m a -> (e -> m a) -> m a
..
power of TwoCont? I mean, it still seems like there's an operation
missing that supplies new left and right continuations at once.
i guess, instead of one DiMonad with two sets
On Mon, Jul 02, 2007 at 12:23:36AM +0200, Hugh Perkins wrote:
Clll :-) Thanks for the link.
Er are you the Philip Armstrong I was at college with
Shhh. Don't tell everyone or they'll all want one. (iow, yes: Probably.)
Phil
--
http://www.kantaka.co.uk/ .oOo. public key:
On Fri, 2007-06-29 at 19:35 +0200, Thomas Schilling wrote:
> On 27 jun 2007, at 18.41, Hans van Thiel wrote:
>
> > [snip]
> >
> > Thanks, Apfelmus, for the references. Guess I'll start there, then.
> > And
> > thanks, Chris, for the info and code. Read only 'up pointers' could be
> > what is nee
contrary to monadic parsers, those continuation-based parsers
had *two* continuations, one for success, one for failure. and
that seemed to be a very natural match for the problem.
Two-continuations is a monad too, right?
yes, but my problem is not about giving them a monadic interface,
but ab
Paul Hudak wrote:
>
>readFile :: Name -> FailCont -> StrCont -> Behaviour
>
> Here StrCont was the success continuation, which took a string (the file
> contents) as argument. I rather liked the flexibility that this offered
> -- since I/O errors were fairly common, it made sense to give succ
Gregory Propf wrote:
Thanks, that was helpful. I didn't realize that there were pure
functional monads.
Actually, it's stronger than that. All monads are pure functional, even
IO. Haskell is an entirely 100% pure functional language[*]. The IO
monad allows you to build up, in a pure, refere
37 matches
Mail list logo