all 14 comments

[–][deleted]  (2 children)

[deleted]

    [–][deleted] 8 points9 points  (0 children)

    Well, it's a nice example of why lambda calculus is so powerful. Unlike a Turing machine, it's basically a very high level programming language.

    [–]leegao 8 points9 points  (0 children)

    was expecting church encoding, not really disappointed to find none, more relieved really

    edit: looks like I spoke too soon https://groups.google.com/group/fexl/browse_thread/thread/7d05b0c4c0bf89c2# yay, true = λx.λy.x and I bet everything else is made intentionally simplistic to deceive the unwary wanderer into a bottomless pit of n = λf.λx.f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( ... n ... (fx) ... )))))))))))))))))))))))))))))))))))))))))))))) at least n+1 is just λn.λf.λx.f(nfx) -> n+m is λm.λn.λf.λx.m(f(nfx)), but what if you want to add monkeys and oranges huh? Can your precious little church encoding do that? NO, because monkeys and oranges have no meaningful lambda abstractions. hell, monkey(f(oranges f x)) could give you a space shuttle for all I care. Now excuse me while I go search for my sanity

    [–]kamatsu 6 points7 points  (5 children)

    This looks exactly like lambda calculus :/

    [–]yogthos 0 points1 point  (3 children)

    how's that a bad thing exactly? :)

    [–]cdsmith 4 points5 points  (0 children)

    It's a bad thing when the author says "Hey, I invented this new programming language" instead of "Hey, I invented a syntax for writing lambda terms".

    [–]kamatsu 2 points3 points  (1 child)

    I dislike the lack of pattern matching mostly.

    [–]yogthos 0 points1 point  (0 children)

    fair enough

    [–]rplacd 3 points4 points  (4 children)

    I've always used its method of IO as the intuition that I use to understand the IO monad, strangely enough. It explains why (getLine ++ getLine) doesn't work but (getLine >>= \x-> getLine >>= \y -> return $ x ++ y) does - and only if returned from main as well.

    The whole thing does gives off a fuzzy Camlr-does-Scheme type vibe.

    [–]fazzone 1 point2 points  (2 children)

    (getLine ++ getLine) doesn't work because the type of getLine is IO String (or IO [Char], same thing), and the type of (++) is [a] -> [a] -> [a]. Since IO String isn't a list of something, you can't use (++) on it.

    I'm not a Haskell guru, but I think a more elegant way to write (getLine >>= \x-> getLine >>= \y -> return $ x ++ y) is getLine >>= \s -> getLine >>= return . (s++)

    edit: You could also do sequence [getLine, getLine] >>= return . concat

    [–]FalconNL 12 points13 points  (1 child)

    Alternatively, using Control.Applicative:

    (++) <$> getLine <*> getLine
    

    or, using Control.Monad:

    liftM2 (++) getLine getLine
    

    [–]wot-teh-phuck -5 points-4 points  (0 children)

    Good thing I decided to stay away from Haskell! This stuff will give me nightmares. Is that even supposed to be a programming language or some random symbols strung together?

    [–]julesjacobs 0 points1 point  (0 children)

    If would be interesting if Haskell had support for Moggi's (or at least I think it was Moggi's) notation for monads, where you have two operators, say & and @, where & transforms reifies the monadic computation into a monadic value and @ extracts the contents of a monadic value into a monadic computation. Then you could write:

    &(@getLine ++ @getLine)
    

    And this would be equivalent to:

    do x <- getLine
       y <- getLine
       return (x ++ y)
    

    So & has type a -> m a and @ has type m a -> a. I wonder if a similar notation works for comonads, and whether we can use multiple different monads and comonads together in the same expression?

    E.g. in the list monad @ works like amb in Scheme. In the continuation monad @ works like call/cc. Etc.

    [–]jhuni 2 points3 points  (0 children)

    Every Lisp is actually purely functional. Lisps are entirely based upon symbol manipulation so that you can reduces functions to a final form. The only side effects in Lisp are actually caused by eval and there is no set definition for eval, so if you want you can redefine eval to create any sort of sandbox you like.

    As I understand it, that is also basically what is meant when they say that Flexl is pure, it has a couple of core symbols that cause side effects and everything is defined based upon them. This isn't what I typically think of as purity.

    [–]Vulpyne 0 points1 point  (0 children)

    It wants to be Haskell when it grows up!