Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackProgrammer/status/730022579256369152
http://meta.programmers.stackexchange.com/questions/6483/why-was-my-question-closed-or-down-voted/6487#6487
Source Link
gnat
  • 20.5k
  • 29
  • 117
  • 310

I'm new to Haskell, so this is more a high-level conceptual question. I've read this: https://wiki.haskell.org/Real_World_Applications/Event_Driven_Applications and it has this:

run :: Domain -> [Event] -> IO ()

run dm [] = do
  events <- uiUpdate dm
  run dm events
 
run _ (EventExit:_) =
  return ()
 
run dm (e:es) =
  run (dmUpdate dm e) es

So uiUpdate would "generate" events in this case.

I am trying to understand how this works in an application where you need to push events. An example - say you have a GUI where you have a single int counter and three types of event sources:

  • Filesystem
  • Network
  • Human interaction

For simplicity, say the counter needs to be increased or decreased whenever any kind of event happens (e.g. new file added or deleted, HTTP call succeeded or failed, human typed on a keyboard or clicked with a mouse).

How do you push these events into the event loop? Most importantly, I'm not asking for "here's how you can do it", but "here's how real world Haskell applications work". Especially if there are different options that are used in practice.

If you have links to some simple source code that uses event driven programming, I'll certainly appreciate those and be happy to try reading it! Though, at least some basic explanations would help greatly...

I'm new to Haskell, so this is more a high-level conceptual question. I've read this: https://wiki.haskell.org/Real_World_Applications/Event_Driven_Applications and it has this:

run :: Domain -> [Event] -> IO ()

run dm [] = do
  events <- uiUpdate dm
  run dm events
 
run _ (EventExit:_) =
  return ()
 
run dm (e:es) =
  run (dmUpdate dm e) es

So uiUpdate would "generate" events in this case.

I am trying to understand how this works in an application where you need to push events. An example - say you have a GUI where you have a single int counter and three types of event sources:

  • Filesystem
  • Network
  • Human interaction

For simplicity, say the counter needs to be increased or decreased whenever any kind of event happens (e.g. new file added or deleted, HTTP call succeeded or failed, human typed on a keyboard or clicked with a mouse).

How do you push these events into the event loop? Most importantly, I'm not asking for "here's how you can do it", but "here's how real world Haskell applications work". Especially if there are different options that are used in practice.

If you have links to some simple source code that uses event driven programming, I'll certainly appreciate those and be happy to try reading it! Though, at least some basic explanations would help greatly...

I'm new to Haskell, so this is more a high-level conceptual question. I've read this: https://wiki.haskell.org/Real_World_Applications/Event_Driven_Applications and it has this:

run :: Domain -> [Event] -> IO ()

run dm [] = do
  events <- uiUpdate dm
  run dm events
 
run _ (EventExit:_) =
  return ()
 
run dm (e:es) =
  run (dmUpdate dm e) es

So uiUpdate would "generate" events in this case.

I am trying to understand how this works in an application where you need to push events. An example - say you have a GUI where you have a single int counter and three types of event sources:

  • Filesystem
  • Network
  • Human interaction

For simplicity, say the counter needs to be increased or decreased whenever any kind of event happens (e.g. new file added or deleted, HTTP call succeeded or failed, human typed on a keyboard or clicked with a mouse).

How do you push these events into the event loop? Most importantly, I'm not asking for "here's how you can do it", but "here's how real world Haskell applications work". Especially if there are different options that are used in practice.

Source Link
levant pied
  • 325
  • 3
  • 10

Event driven programming in Haskell

I'm new to Haskell, so this is more a high-level conceptual question. I've read this: https://wiki.haskell.org/Real_World_Applications/Event_Driven_Applications and it has this:

run :: Domain -> [Event] -> IO ()

run dm [] = do
  events <- uiUpdate dm
  run dm events
 
run _ (EventExit:_) =
  return ()
 
run dm (e:es) =
  run (dmUpdate dm e) es

So uiUpdate would "generate" events in this case.

I am trying to understand how this works in an application where you need to push events. An example - say you have a GUI where you have a single int counter and three types of event sources:

  • Filesystem
  • Network
  • Human interaction

For simplicity, say the counter needs to be increased or decreased whenever any kind of event happens (e.g. new file added or deleted, HTTP call succeeded or failed, human typed on a keyboard or clicked with a mouse).

How do you push these events into the event loop? Most importantly, I'm not asking for "here's how you can do it", but "here's how real world Haskell applications work". Especially if there are different options that are used in practice.

If you have links to some simple source code that uses event driven programming, I'll certainly appreciate those and be happy to try reading it! Though, at least some basic explanations would help greatly...