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

Monadic Linear Algebra

Name: Anonymous 2008-11-29 0:45

I'm trying to learn Haskell and I want to create a monad that, when you pass it two matrices, multiplies them, and then takes the inverse. But I cant figure out how, can anyone HELP ME?

Name: Anonymous 2008-11-29 2:21

>>1
Why would this need to be a monad?

Name: Anonymous 2008-11-29 3:22

>>2
because that's the only way to do anything useful in haskell.

Name: Anonymous 2008-11-29 4:00

>>3
But... matrix multiplinversion needs no side effects.

Name: Anonymous 2008-11-30 9:12

I want MONADS! MONADS, MONADS, MONADS! I want MONADS for my fibonacci function, and MONADS for my factorial function. I want MONADS!

Give me MONADS!

Name: Anonymous 2008-11-30 14:07

>>5
here, have some lemonade

Name: Anonymous 2008-11-30 16:43

What are monads?

Name: Anonymous 2008-11-30 16:55

(″・ิ_・ิ)っ-̾ A monad is a functor from a category to itself. Honestly, I don't know how I could make this any simpler.

Name: Anonymous 2008-11-30 17:01

>>8
Hehe, but what is a functor?

Name: Anonymous 2008-11-30 17:15

and what is a category?

Name: Anonymous 2008-11-30 17:19

And what is a nomad?

Name: Anonymous 2008-11-30 17:20

and what is love?

Name: Anonymous 2008-11-30 17:47

baby, don't hurt me

Name: Anonymous 2008-11-30 17:52

baby, don't hurt me
baby, don't hurt me
no more

Name: Anonymous 2008-11-30 17:59

>>9
“Functor” is an abstract interface for container types. It has a single method, “fmap”, which applies a function f to each element x of the container, replacing it with f(x), but leaves the shape of the container unchanged. In Haskell syntax it looks like this:

class Functor f where
    fmap :: (a -> b) -> f a -> f b


Lists implement this interface, and fmap on lists is just the usual map function. But fmap also works on Maybe a:

instance Functor Maybe where
    fmap f x = case x of
        Nothing -> Nothing
        Just x  -> Just (f x)


(This definition is more or less obvious if you view Maybe a as a list of at most one element.)

“Monad” is a subclass of Functor, adding two methods: “return”, which wraps a single element in a container, and “join”, which turns a container of containers into a plain container, collapsing some of the intermediate structure. Here are a few sample definitions:

-- Maybe
return :: a -> Maybe a
return x = Just x

join :: Maybe (Maybe a) -> Maybe a
join (Just (Just x)) = Just x
join _ = Nothing

-- Lists
return :: a -> [a]
return x = [x]

join :: [[a]] -> [a]
join = concat

Name: Anonymous 2008-11-30 18:00

>>10
A miserable little pile of morphisms.

Name: Anonymous 2008-11-30 20:30

I'd love to explain to you how to write hello world in Haskell, but first let me introduce you to basic category theory.

Name: Anonymous 2008-11-30 21:16

>>15
So is bind just the same as fmap?

Name: Anonymous 2008-12-01 1:05

>>16
No, bind is a functor mapping the set of nonempty free monoids to an isomorphic set of free monoids each having at most one element. fmap is defined as in >>15.

Name: Anonymous 2008-12-01 4:47

>>18
No, bind is defined as:
bind x f = join (fmap f x)

Name: Anonymous 2008-12-01 5:01

>>18
http://en.wikibooks.org/wiki/Haskell/Category_theory has useful information about the relationship between join/fmap/return/>>=.

Name: Anonymous 2009-03-06 8:45


from obfuscating C or   some stupid shit   like that but   without rotting your.

Name: Anonymous 2009-03-06 13:33

With JavaShit support can support pretty much   the equivalent of   while 1 printf   EXPERT n break   all read Nothing   do not try   last head drop   catch all break.

Name: Anonymous 2009-03-06 13:34

Needlessly and unexpectedly destructive The fucking documentation   for sort says.

Name: Anonymous 2010-12-09 23:27


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