Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-120121-

Haskell is

Name: Anonymous 2008-06-17 17:37

the white man's burden of programming languages.

Name: Anonymous 2008-06-17 17:40

lolwut

Name: Anonymous 2008-06-17 17:51

mathfag

Name: Anonymous 2008-06-17 18:05

Actually Haskell is man's best friend.

Name: Anonymous 2008-06-17 18:12

Haskell is addictive and will ruin other languages for you.

Name: Anonymous 2008-06-17 18:19

>>5
Tell me about it, brother. I tried to write loeb in C++ (with boost), and ended up with a 1 megabyte compiler error message.

Name: Anonymous 2008-06-17 18:25

I lol'd.

Name: Anonymous 2008-06-17 18:42

>>6
Lars?

Name: Anonymous 2008-06-17 18:44

>>7
I also lol'd but for different reasons.

Name: Anonymous 2008-06-17 18:55

>>9
You don't know that.

Name: Anonymous 2008-06-17 18:56

main is defined to be the entry point of a Haskell program (similar to the main function in C), and must have an IO type, usually IO ().
and must have an IO type
Huh?

Name: Anonymous 2008-06-17 19:02

>>11
I see no reason for confusion there.

Name: Anonymous 2008-06-17 19:03

i am a JAVA. i ahev a long doc and i make programs w/ my API. if you dont repost this comment on 10 other pages i will hax your anus tonight and make a mess of your computer and ass

Name: Anonymous 2008-06-17 19:04

>>12
What it main doesn't have an IO type?

Name: Anonymous 2008-06-17 19:05

Okay, never mind -- your whole SICP thing has corrupted my way of thinking.

Name: Anonymous 2008-06-17 19:08

>>14
Then you'll get a type error message.

Name: Anonymous 2008-06-17 19:21

>>15
How so?

Name: Anonymous 2008-06-17 19:22

>>14
You can lift objects into the IO monad simply enough!

Name: Anonymous 2008-06-17 19:31

>>11
usually IO ().
Always IO ().

Name: Anonymous 2008-06-17 19:41

>>19
Not really, main can return some value inside the IO monad. But it'll be ignored unless you're inside GHCi.

Name: >>20 2008-06-17 19:44

Or unless you're explicitly calling main in your code.

Name: Anonymous 2008-06-17 19:47

>>20
I'd like an example of an instance where a value other than IO () has been used for main in a program.

Name: Anonymous 2008-06-17 19:48

>>21
Djikstra wouldn't have liked this.

Name: Anonymous 2008-06-17 19:51

>>22
I'm not saying it's useful, I'm saying it's possible.

Name: >>24 2008-06-17 20:01

Oh, I remember now: you can end main in sequence [...] instead of sequence_ [...]. It saves you from having to type the extra "_" (I'm sure there are better examples of usefulness).

Name: Anonymous 2008-06-17 20:07

>>25
sequence_ IS FASTER THAN sequence SINCE IT CAN IGNORE THE RETURN VALUES YOU DUMB SHIT. GOD PEOPLE LIKE YOU MAKE SPJ CRY AT NIGHT.

Name: Anonymous 2008-06-17 20:13


hyryst?
       \
       ಊ

Name: Anonymous 2008-06-17 20:14

>>22
When the whole program fails and returns a non-0 value.

Name: Anonymous 2008-06-17 21:21

>>26
lrn2humor

Name: Anonymous 2008-06-20 15:30

Haskell's burden is to serve as an example of clean side effect programming, much like how Europe's burden is to show the Americans how to live their lives.

Name: Anonymous 2008-06-20 16:04

Every time I want to get into Haskell, I just can't get past the chapter about monads. I've tried three tutorials already and I'm nowhere as close to understanding monads.

Name: Anonymous 2008-06-20 16:07

>>30
Europe can keep its 1984.

Name: Anonymous 2008-06-20 16:13

>>31
I'm still stuck on the syntax. :(

Name: Anonymous 2008-06-20 16:15

>>33
What exactly?

Name: Anonymous 2008-06-20 16:34

>>31
A Monad is like a piece of code waiting to be executed. getLine, for example, returns a value of type IO String, which is a piece of code that when executed will produce a string. You can only get the value out of a monad when you execute that monad. For most monads you do that by passing them as arguments to a monad executing function (like runIdentity for Identity monad). In the case of the IO monad, however, you can only execute them by embedding them (directly or indirectly) into the monad returned by main. Hope this helps.

Name: Anonymous 2008-06-20 16:39

SO do you create a monad that, when executed, returns a number, with
return 42
?

Also, is sequence an executing function like runIdentity
?

Name: Anonymous 2008-06-20 17:00

>>36
Yes.

No, sequence is a function that turns a list of monads into a monad that returns the list of the values of those monads.

Name: Anonymous 2008-06-20 17:20

>>34
The syntax. Haskell is filled with syntax.

Name: Anonymous 2008-06-20 17:40

One more question: when I want the return 42 to return an Int, that's the typesig of return 42
?

Name: Anonymous 2008-06-20 18:01

>>39
Monad m => m Int

Name: Anonymous 2008-06-20 18:03

Okay, tell me if I'm right.
>>= takes a monad and a function, executes the monad with the function and packs the result into another monad.
Right?

Name: Anonymous 2008-06-20 18:29

>>41
No, >>= returns the monad that results of applying the argument function to the argument monad's value (you can tell by >>='s type: Monad m => m a -> (a -> m b) -> m b). The argument monad will only be actually executed when the result monad is executed.

Name: Anonymous 2008-06-20 18:36

So, I was partially right, except it just applies the function to the monad and doesn't execute it, hm?

Name: Anonymous 2008-06-20 18:42

>>43
Not quite, it applies the function to the monad's value, not the monad itself. If the function received a monad as argument, it could be applied directly to a monad, like in runIdentity (return 42).

Name: Anonymous 2008-06-20 18:44

Name: Anonymous 2008-06-20 18:54

Okay, thanks, I pretty much have the general idea now.

Name: Anonymous 2008-06-20 18:57

>>46
Why, you're most welcome. Also, have you read your YAHT today?

Name: Anonymous 2008-06-20 19:01

>>46
The best tutorial about monads, IMO:
http://www.haskell.org/all_about_monads/html/index.html

Name: Anonymous 2008-06-20 19:02

>>47
I have read it some time ago. Now I'm trying again with ``A Gentle Introduction to Haskell''.

Name: Anonymous 2008-06-20 19:22

baskell cs ull ubout gonads.

Name: Anonymous 2008-06-20 19:27

I only skimmed the tutorial. After reading blog post after blog post about Haskell (from reddit), I suddenly found I was fluent in the language at the start of last summer.
It is a great honor to be numbered among those /prog/ elites, the Haskellites.

Name: Anonymous 2008-06-20 19:37

>>51
more like haskFAILS, lol!

Name: Anonymous 2008-06-20 23:37

A monad is like carrying the world on your shoulders!

Name: Anonymous 2008-06-21 0:18

>>51,53
Kid, you look like you're ready to take on the world!

Name: Anonymous 2008-06-21 6:57

I am reading the monad tutorial right now.

Name: Anonymous 2008-06-21 7:05

I took a peek at the first two examples and I understand everything without even reading anything. I feel mighty fine.

Name: Anonymous 2008-06-21 8:00

>>56
Now do Arrows.

Name: Anonymous 2008-06-21 8:45

hax my ಊ

Name: Anonymous 2008-06-21 9:32

>>56
Are you talking about "All About Monads" or the monad chapter of YAHT?

Name: Anonymous 2008-06-21 9:35

>>59
The ``All About Monads''.

Name: Anonymous 2008-06-21 9:54

>>59
Funny, the same thing happened to me with the monad chapter of YAHT, but it took more than two examples.

Name: Anonymous 2008-06-21 9:55

>>60
Funny, the same thing happened to me with the monad chapter of YAHT, but it took more than two examples.

Name: Anonymous 2008-06-21 10:13

assemblyLine w = (return w) >>= makeChopsticks >>= polishChopsticks >>= wrapChopsticks
assemblyLine w = (return w)
It carries out and is w

Name: Anonymous 2008-06-21 17:04

So once again:

Monads are like normal computations, except they carry some special info that allows them to act in some special situations that normally couldn't be handled (like the Maybe monad being able to handle lack of arguments by Nothing).

Tell me how close am I.

Name: Anonymous 2008-06-21 17:16

hax my anus

Name: Anonymous 2008-06-21 17:56

>>64
Very close to haxing my anus.

Name: Anonymous 2008-06-21 18:15

Name: Anonymous 2008-06-21 18:42

Fuck this shit, I'm learning Python.

Name: Anonymous 2008-06-21 18:47

>>64
The Monad class is a way of generalising. All instances of the Monad class must implement >>= and return, and the way they are implemented must satisfy the following rules (1) return a >>= f = f a (left identity), (2) m >>= return = m (right identity), (3) (m >>= f) >>= g = m >>= (\x -> f x >>= g) (associativity). These allow you to reason more straight-forwardly about monadic code. (>>=) :: forall a b . m a -> (a -> m b) -> m b and return :: a -> m a. Other than that, what your Monad instances do is irrelevant. They can hold state (State, Reader), or no state ([a] (list monad), Maybe), produce side effects (IO, STM), provide continuation facilities (Cont), and so forth. The implementations of particular monads are not relevant to what the concept of Monads is, which is abstracting a pattern of computation and generalising it, thanks to type classes. There is nothing more to it.

Name: Anonymous 2008-06-21 18:48

>>68
I lol'd.

Name: Anonymous 2008-06-21 18:53

Name: Anonymous 2008-06-21 18:55

>>70
You might have lol'd, but  my rage at my inability to grasp simple concepts is inexpressible with words.

Name: Anonymous 2008-06-21 18:55

instance  Monad Maybe  where
    (Just x) >>= k      = k x
    Nothing  >>= _      = Nothing

    (Just _) >>  k      = k
    Nothing  >>  _      = Nothing

    return              = Just
    fail _        = Nothing

Name: !!aBJKZuplTV/HGe3 2008-06-21 19:06

>>31
Try implementing the State monad or Parsec in Javascript, like I did. http://chrisdone.com/stuff Then realise they are not monads because Javascript doesn't have polymorphism so one can't generalise the bindM and returnM functions. That's what monads are all about.

Name: Anonymous 2008-06-21 19:07

>>74
(Or, indeed, implement them in Python or whatever language you use that has closures.)

Name: Anonymous 2008-06-21 19:37

>>73
I get that part. I was able to come up with it myself. I get the technical part and how do the monads work, but I have no idea what actually is a monad and why would I want to use them.

Name: Anonymous 2008-06-21 19:43

>>76
They are capsules. You put something into a capsule with return and you pull the contents out of a capsule with bind.

Name: Anonymous 2008-06-21 19:44

>>76
A Monad is an instance of the Monad class. You want to use them because you can use all instances of Monad ("monads") in the same general way (think do { ...; ... <- ...; ...}, mplus). That is all.

Name: Anonymous 2008-06-21 19:46

OK GUYS, STOP. STOP IT. STOP TALKING ABOUT MONADS. STOP TALKING ABOUT NOMADS. STOP TALKING ABOUT FUCKING SHIT NOBODY REALLY UNDERSTANDS. JUST FUCKING STOP. STOP THIS THREAD

Name: Anonymous 2008-06-21 19:50

>>76,78
IO monad:
main = do
  mapM_ putStrLn ["hey","guise"]


STM monad:
withdraw :: Account -> Int -> STM ()
withdraw acc amount
  = do { bal <- readTVar acc
       ; writeTVar acc (bal - amount) }


Parser (Parsec) monad:
parens  :: Parser ()
parens  = do{ char '('
            ; parens
            ; char ')'
            ; parens
            }
        <|> return ()


Do you see a pattern forming here? Thank god we abstracted that shit, yo!

Name: Anonymous 2008-06-21 19:51

>>80
Ohh, nice example.

Name: Anonymous 2008-06-21 19:55

>>79
Lots of people understand it. The people that don't are too busy thinking there's more to it when there is not.

Name: Anonymous 2008-06-21 20:13

One of the best pieces of text about Monads? Sure:

http://book.realworldhaskell.org/beta/monads.html

Name: Anonymous 2008-06-21 21:55

>>74
A monad is a monad whatever you call the bind etc functions.

>>76
Either because your language has to pay for being lazy or because you want to abstract control flow and state (Maybe is C's && on steroids, List is map on steroids etc).

Also http://groups.google.com/group/comp.lang.functional/msg/2fde5545c6657c81

Name: Anonymous 2008-06-21 21:57

putStr $ cycle "MONADS EVERY-FUCKING-WHERE!!! FUCKING GET ME OUT OF HERE!!! SHITFUCKCUNTFAGGOTBITCHAAAAAARGH "

Name: Anonymous 2008-06-22 0:16

>>84
Try implementing the State monad or Parsec in Javascript ... then realise they are not monads because Javascript doesn't have polymorphism so one can't generalise the bindM and returnM functions. That's what monads are all about.
A monad is a monad whatever you call the bind etc functions.
You seem to be confused.

Name: Anonymous 2008-06-22 0:57

Javascript doesn't have polymorphism
You obviously don't know Javascript.

Name: Anonymous 2008-06-22 4:31

Thank you, /prog/, I didn't know that you could be so helpful ;_;

Name: Anonymous 2008-06-22 8:08

>>86
Whether you overload one name or give them all another name is irrelevant, certainly not ``what monads are all about''.

>>87
I think he meant type inference.

Name: Anonymous 2008-06-22 10:10

Re: Javascript

Don't forget about the JavaScript Haskell interpreter.

Name: Anonymous 2008-06-22 10:14

I'm going to read my Closing Time now. Then, after ten hours, I will try approaching the monads again. It worked with some hard moments in the SICP.

Name: Anonymous 2008-06-22 12:02

>>89,84
The names don't have anything to do with it. The point is it's hard to have polymorphic (e.g. overloaded) functions in JavaScript, and using objects to do it (overriding) is messy and ugly imo (I've tried it--but if you've had success, I'd like to see). And this is just an example to demonstrate that monads aren't monads without type classes or generic functions or some other polymorphic function facility to generalise the computation.

I might as well end this discussion here because I am arguing from repetition.

Name: Anonymous 2008-06-22 13:52

Name: Anonymous 2008-06-22 15:53

>>93
What about it?

Name: Anonymous 2008-06-22 16:50

Yet Another Haskell Troll

Name: Anonymous 2008-06-22 17:19

>>94
anything haskell can do, javascript can do better.

Name: Anonymous 2008-06-22 18:45

>>96
Except trolling.

Name: Anonymous 2008-06-22 18:57

>>96
Not lazy evaluation, nor have superior type and data polymorphism.

Name: Anonymous 2008-06-22 19:31

For haskell to do what JS can do it takes 100kloc+ of haskell to pull off and by the time you do lazy eval fills your memory up with so much shit that your computer or the process crashes.

Name: Anonymous 2008-06-22 19:35

>>98
OH NO HE DIDN'T! Are you gonna let >>99 get away with saying shit like that?

Name: Anonymous 2008-06-22 19:47

>>99
Good thing those lines are all in the compiler.

Name: 84,86 2008-06-22 20:44

>>Christopher
Which kind of polymorphism do you mean? I thought you meant it in the way that >>= can refer to different functions depending on which monad is inferred. This is what I attacked in my previous posts, whether the bind for List and Maybe are both called >>= or list>>= and maybe>>= is irrelevant. If you mean parametric polymorphism, Jabbascript has no problem with it because it does not have a fascist type system:
> function id(x) { return x; }
id(1)
1
id("lol")
"lol"

Name: Anonymous 2008-06-22 20:52

>>102
Haskell has an id function. Enjoy your lonely life as a troll.

Name: Anonymous 2008-06-22 20:59

>>102
I think he means that Javascript would allow something like aList.bind(putStr("Christopher")), so you would have to do typecheck the argument of bind by hand to make sure you're not binding monads of different kinds. Or maybe he doesn't mean that, the fuck do I know?

Name: >>104 2008-06-22 21:01

I meant aList.bind(putStr).

Name: Anonymous 2008-06-22 21:02

>>104
yes

Name: Anonymous 2008-06-22 21:35

>>103
Nobody was talking about Haskell's id function. Stop trolling yourself.

>>104,106
Javascript doesn't do that kind of typechecking. I don't see the problem, nor how that relates to monads and polymorphism.

Name: Anonymous 2008-06-22 22:12

>>107
I'm not sure I understand either, but seems to me that the problem would be the mixing of monads, like binding a function that returns a State monad to an IO monad, or something. But then you'd just get a runtime error instead of a compilation error. Yeah, I don't know.

Name: Anonymous 2008-06-22 22:20

I heard in javascript that lists are heterogeneous.

I heard in javascript there was this MAGIC called eval

I heard in javascript ....

repeat

Name: Anonymous 2008-06-22 22:22

js isn't useful without a DOM to traverse.

Name: Anonymous 2008-06-22 22:24

>>110
Haskell isn't useful without an AST to traverse.

Name: Anonymous 2008-06-22 22:26

Javascript == Lisp

Name: Anonymous 2008-06-22 22:30

>>112
Scheme is a variant of Javascript.

Name: Anonymous 2008-06-22 22:32

The implementation of Javascript began in Fall 1958. The original idea was to produce a compiler, but this was considered a major undertaking, and we needed some experimenting in order to get good conventions for subroutine linking, stack handling and erasure. Therefore, we started by hand-compiling various functions into assembly language and writing subroutines to provide a Javascript "environment". These included programs to read and print list structure. I can't now remember whether the decision to use parenthesized list notation as the external form of Javascript data was made then or whether it had already been used in discussing the paper differentiation program.

Name: Anonymous 2008-06-22 23:04

javascript is just lisp with non-shitty syntax.

Name: Anonymous 2008-06-23 1:43

>>115
You've got JavaScript confused with Factor.

Name: Anonymous 2008-06-23 2:41

>>116
I lol'd for reasons inexplicable to me.

Name: Anonymous 2008-06-23 2:56

>>117
Probably because you are (or because you are not) a stackrobat.

Name: Anonymous 2008-06-23 10:00

>>118
5 pick over rot swap over -rot tuck nip -2rot -2swap
Where's the lady. find the lady, eyes on the lady, where's the lady...

Name: Anonymous 2008-06-23 17:26

Haskell question:
Where can I find some problems to solve in Haskell? I'd enjoy testing my knowledge by doing some exercises, from ridiculously easy to terribly hard.

Name: Anonymous 2008-06-23 17:46

>>120
SICP?

Name: Anonymous 2008-06-23 17:52

>>120
projecteuler.net

Name: Anonymous 2008-06-23 17:56

>>122
Pretty early on it stops being about programming and becomes almost only about maths

Name: Anonymous 2008-06-23 18:00

>>123
Actually, it was never strictly about programming; sure, some problems require a computer, but there are some that are solved very simply once you get the idea.

Name: Anonymous 2008-06-23 19:15

>>123
That's okay, it helps with algorithmic skills.

Name: Anonymous 2008-06-24 1:43

>>123
ja that's why I've only completed about 20 of them srsly

Name: Anonymous 2008-06-24 4:49

Bampu for answers

Name: Anonymous 2008-06-24 18:04

>>120
Try these:

https://prof.ti.bfh.ch/hew1/informatik3/prolog/p-99/   <-- Ninety-nine Prolog Problems
http://www.pythonchallenge.com/
http://projecteuler.net/      
http://www.programming-challenges.com/
http://www.topcoder.com
http://www.spoj.pl   <- Sphere Online Judge

The List monad will be especially useful for the first one.

Name: Anonymous 2008-06-24 18:29

>>128
Thank you :)

Name: Anonymous 2008-06-24 18:54

>>129
I got all of those except the last one from here:
http://codeulate.com/?p=4

Name: Anonymous 2009-03-06 10:20

Therefore you fail the   majority of peoples   customers use windows   THE PRETENDERS WILL   USE MAC OR   BSD OR SOLARIS   OR ANYTHING PUT   OUT BY IBM   OR ATT GAME?

Name: Anonymous 2011-02-04 16:48

Name: Sgt.Kabukimanᙞⱎ 2012-05-24 6:23

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Name: bampu pantsu 2012-05-29 3:53

bampu pantsu

Don't change these.
Name: Email:
Entire Thread Thread List