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

Pages: 1-

How to understand arrows!

Name: Ponster Menis !Ep8pui8Vw2 2007-03-17 10:59 ID:cyRS7xdF

Allow me to translate these function definitions into what they really are!

(>>>) :: a b c -> a c d -> a b d
  (>>>) :: (b -> c) -> (c -> d) -> (b -> d)

first :: a b c -> a (b, d) (c, d)
  first :: (b -> c) -> ((b, d) -> (c, d))


Yes, functions are arrows, that's why this works!

Knowing this is really good when you are doing random numbers:
random = first (\ n -> ...) . next
Look up the specifications and you'll see that random (in the class Random) should take a RandomGen and return (x, g) where x is the random value and g is the generator.  next returns a similar pair with an int and the new generator that should be returned.

It's magic I'm telling you!

Name: Anonymous 2007-03-17 11:05 ID:V5AZVDcr

ARROWS ARE REALLY USEFUL, CHECK THIS MINDHACK OUT


Prelude Control.Arrow> (snd &&& fst) (1,2)
(2,1)


WOOHOO!

Name: Anonymous 2007-03-17 14:42 ID:mZahUIZq

Forced arbitrary of syntax, thread over.

Name: Anonymous 2007-03-17 14:42 ID:mZahUIZq

>>3
infact scap that, the whole language is arbitrary.

Name: test 2007-11-03 19:45

*̡͌l̡*̡̡ ̴̡ ı̴̴ ̡̡|̲͡ ̲▫̲͡ ̲͡ π̲͡ ̲͡▫̲͡ ̲ ̲͡▫̲͡ ̲ ̲͡▫̲͡ ̲ ̲͡▫̲͡▫̲͡ ̲|̡̡ ̡ ̡ ̴̡ ı̴̴ ̡*̡͌l̡*

Name: Anonymous 2009-01-14 12:48

LISP

Name: Anonymous 2011-02-04 17:10

<

Name: Sgt.Kabuᗿ鱻kiman湚 2012-05-28 23:25

Bringing /prog/ back to its people
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

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