summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar http://claimid.com/strager <http://claimid.com/strager@web>2012-08-11 16:08:47 +0000
committerGravatar admin <admin@branchable.com>2012-08-11 16:08:47 +0000
commitfb29916e483f528d914e3ef9c73b23210dbf4a45 (patch)
treea20b0d5e97db46b23b982785ee023fd3a63ec0c7
parent876b4c652ce195f82e535b4ed7f423bcb59c885b (diff)
Added a comment
-rw-r--r--doc/design/assistant/blog/day_57__afk/comment_4_8b1f65f141ffd9813e7f5a3380f7f520._comment27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/design/assistant/blog/day_57__afk/comment_4_8b1f65f141ffd9813e7f5a3380f7f520._comment b/doc/design/assistant/blog/day_57__afk/comment_4_8b1f65f141ffd9813e7f5a3380f7f520._comment
new file mode 100644
index 000000000..c87e447d1
--- /dev/null
+++ b/doc/design/assistant/blog/day_57__afk/comment_4_8b1f65f141ffd9813e7f5a3380f7f520._comment
@@ -0,0 +1,27 @@
+[[!comment format=mdwn
+ username="http://claimid.com/strager"
+ ip="173.228.13.253"
+ subject="comment 4"
+ date="2012-08-11T16:08:47Z"
+ content="""
+> How to cancel download? Depends on its implementation .... So it's an abstraction layer violation problem.
+
+Precisely why I suggested returning something as generic as `IO ()`:
+
+ -- Current
+ download :: URLString -> Headers -> [CommandParam] -> FilePath -> IO Bool
+
+ -- Suggestion
+ data Transfer a = Transfer { run :: IO a, cancel :: IO () }
+ download :: URLString -> Headers -> [CommandParam] -> FilePath -> Transfer
+
+ transfer <- download ...
+ -- You can pass `cancel transfer` to another thread
+ -- which you want to be able to cancel the transfer.
+ run transfer -- blocking
+
+I realized while writing this that you may not get any result from e.g. a download while it is occurring (because the function is blocking). Maybe that's where a misunderstanding occurred. I separated the concepts of creating a transfer and starting/canceling it.
+
+(My idea is starting to feel a bit object-oriented... ;P)
+
+"""]]