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

instance (Num a) => Num [a]

Name: Anonymous 2013-03-11 20:18

instance (Num a) => Num [a] where
        xs + ys = [x + y | x <- xs, y <- ys ]
        xs * ys = [x * y | x <- xs, y <- ys ]
        abs = map abs
        signum = map signum
        fromInteger x = [fromInteger x :: (Num a) => a]

Name: Anonymous 2013-03-11 20:37

xs + ys = [x + y | x <- xs, y <- ys ]

(+) = liftA2 (+)

Name: Anonymous 2013-03-11 21:50

>>1
Do you even liftA2?

Name: Anonymous 2013-03-12 4:02

* doesn't distribute over +

λ> [1,2] * ([3,4,5] + [6,7])
[9,10,10,11,11,12,18,20,20,22,22,24]
λ> [1,2] * [3,4,5] + [1,2] * [6,7]
[9,10,15,17,10,11,16,18,11,12,17,19,12,13,18,20,14,15,20,22,16,17,22,24]

Name: Anonymous 2013-03-13 13:24

xs * ys = [x * y | x <- xs, y <- ys ]
Have you read your Monads today?

Name: Anonymous 2013-03-13 15:06

HASKAL THE DEAD NOSE

Name: Anonymous 2013-03-13 15:26

Haskell is very hard, but even after 3 years of pretty intensive use, I never really felt productive with haskell in the same way that I've felt in other languages. Anything I did in haskell required a lot of thinking up-front and tinkering in the REPL to make sure the types all agreed and it was rather time-consuming to assemble a selection of data types and functions that mapped adequately onto the problem I was trying to solve. More often than not, the result was something of an unsightly jumble that would take a long time to convert into nicer-looking code or to make an API less terrible to use.

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