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

/prog/ challenge [HASKELL]

Name: Anonymous 2008-05-09 13:15

Use the loeb function:
loeb :: Functor a => a (a x -> x) -> a x
loeb x = fmap (\a -> a (loeb x)) x


To implement a basic spreadsheet processor. The processor should accept input of the form:
|##|A        |B    |C   |D       |
|01|(* B1 C1)|2    |3   |(* A1 2)|

The output from this example should be:
|##|A      |B    |C   |D     |
|01|6      |2    |3   |12    |

Cells may contain number literals, references to other cells of the form <letter><number>, or function applications of the form (<function> *<args>).

Name: hasklol 2009-07-01 14:02

>>8
Haskell was made without side-effects (lol pure). Then everyone was like, "Fuck, we need sonuvabitching side-effects to do any goddamn thing!" So they let them back in. But then they were like, "Shit, lazy evaluation means crap is happening in fucked-up ways we can't motherfucking cocksucking asshole dick predict!" Hence, monads.

IOW: Monads are a way of [doing what every other language already does by] separating purity and impurity in a lazy language.

...

For the sake of clarity. XD XD XD

Name: Anonymous 2009-07-01 14:31

>>60
facepalm.txt

Name: Anonymous 2009-07-01 14:39

>>60
Nice try, thanks for playing. Monads actually have nothing to do with laziness, and everything to do with passing around arguments you don't care about, especially in recursive code.

Name: !MILKRIBS4k 2009-07-01 16:23

I don't "get" what is up with this HASKELL meme! Why is it so good! Is it better than C! Why is it not on as many platforms as C if it's so good! Is this all just a /prog/ meme!

Name: Anonymous 2009-07-01 16:29

>>63
You have no idea what you're getting into. If you tried to understand Haskell, your head (do anuses have heads?) would explode.

Name: Anonymous 2009-07-01 16:30

>>63
/prog/
You are a quick learner. Get the fuck back to lounge.

Name: !MILKRIBS4k 2009-07-01 16:35

>>64
Are you trying to say HASKELL is some sort of secret club(like /b/) that only the best programmers can use! NO THANK YOU

Name: Anonymous 2009-07-01 16:37

>>66
What I am trying to say now is that you should learn to use the question mark.
And please don't compare Haskell to /b/.
Also, how the hell is /b/ like a secret club?

Name: !MILKRIBS4k 2009-07-01 16:41

>>67
Jeepers I was using sarcasm! Well what is so great about HASKELL! Is it just a meme!

Name: HASKELL MEME FAN 2009-07-01 16:46

>>68
f@(_:fs) = 0 : 1 : zipWith (+) f fs
FACTORIALS!

Name: !MILKRIBS4k 2009-07-01 16:51

>>69
JEEPERS CREEPERS! I just read the wiki on FACTORIALS and I did not understand one thing it said!

Name: Anonymous 2009-07-01 17:00

>>69
f@(_:fs) = 0 : 1 : zipWith (+) f fs
FACTORIALS!

4/10, I nearly didn't notice.

Name: Anonymous 2009-07-01 18:32

>>62
Nice try
So, 4/10? 5/10?
Monads actually have nothing to do with laziness...
Ah, 10/10.

Name: Anonymous 2009-07-01 21:44

>>68
loeb :: Functor a => a (a x -> x) -> a x
loeb x = fmap (\a -> a (loeb x)) x

Name: Anonymous 2009-07-01 21:52

>>72
It's true. Monads are a constuction in category theory.

Name: Anonymous 2009-07-01 22:16

>>72
You have in fact not been trolled. Haskell's monads are completely orthogonal to laziness; in fact, Haskell has some strict monads.

Now if you wanted to implement monads in a language without closures, then you'd be fucked. It would be like trying to compile Ruby.

Name: Anonymous 2009-07-01 22:25

>>75
not been trolled
Lessee:
XD
Stupid smiley? Check.
Laziness and monads
Tying together completely unrelated things? Check.
So then they were like...
Fake history? Check.
>>8
Responding to a post from a zillion years ago? Check.

Yep, sure isn't trollan in here.

Name: Anonymous 2009-07-01 22:57

>>76
Excuse me sir, >>60-chan was clearly a troll, but >>62-chan was probably not. But what do I know?

Name: Anonymous 2009-07-01 23:38

loeb = fix (fmap . flip id =<<)

Name: Anonymous 2009-07-02 0:00

>>78
Add a type signature

Name: Anonymous 2009-07-02 0:45

>>79
loeb :: Functor f => f (f a -> a) -> f a
loeb = fix (fmap . flip id =<<)

Name: Anonymous 2009-07-02 0:49

>>80
or you could just make it [[a] -> a] -> [a], and most people wouldn't know the difference. because really, who uses loeb with anything else?

Name: Anonymous 2009-07-02 4:23

>>80
[m]s/Functor/Monad/
1s/f/m/g[/code]

Name: Anonymous 2009-07-02 4:32

>>82
    Could not deduce (Functor m) from the context (Monad m)
      arising from a use of `fmap' at <interactive>:1:13-16
    Possible fix:
      add (Functor m) to the context of an expression type signature
    In the first argument of `(.)', namely `fmap'
    In the second argument of `(=<<)', namely `fmap . flip id'
    In the first argument of `fix', namely `(fmap . flip id =<<)'

Name: Anonymous 2009-07-02 5:05

new challenge: write the loeb function in a language that isn't haskell, and use it to do something useful.

Name: Anonymous 2009-07-02 6:03

>>84
Rather than taking five seconds to write it in Clean I'll just point out that you can translate it pretty much verbatim from the Haskell version.

Name: Anonymous 2009-07-02 6:47

>>85
and use it to do something useful.

Name: Anonymous 2009-07-02 11:01

Now implement löbM :: (Traversable f, MonadFix m) => f (f a -> m a) -> m (f a).

Name: Anonymous 2010-12-17 1:29

Xarn is a bad boyfriend

Name: Anonymous 2010-12-20 19:23

Name: Sgt.Kabukimanឪ뵾 2012-05-23 5:39

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

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