|
fart simpson posted:i dont mean to be rude but are you sure you took a haskell class at the literal haskell place? he's doing panic revision, the exam's probably tomorrow and he hasn't slept in 2 days. he probably stared blankly at that code for like 30 mins in a fatigued state before giving up and posting here or at least, that's the generous interpretation
|
# ? Apr 28, 2015 19:49 |
|
|
# ? May 25, 2024 12:17 |
|
fleshweasel posted:wow is he completely loving the indentation on the code in order to up the challenge or something the indentation seems ok except for the comment at the top with the example string to parse. the indentation in the input string doesnt really matter, you just need to get a basic idea of what you're dealing with for the given parsers
|
# ? Apr 28, 2015 19:52 |
|
Ploft-shell crab posted:This seems absolutely awful and makes me like Haskell less don't use singly-linked lists for strings and you won't be bitten by this. i really really hate the fact that the good string type that uses arrays, "Data.Text", is in a library whereas the default "String" has absolutely horrendous performance and a whole load of gotchas like this but because it's easy to define* it's in the standard library pretty much every single "i just learnt haskell but why is this simple string manipulation program so slow???" can be attributed to this *: code:
gonadic io fucked around with this message at 19:59 on Apr 28, 2015 |
# ? Apr 28, 2015 19:52 |
|
gonadic io posted:he's doing panic revision, the exam's probably tomorrow and he hasn't slept in 2 days. he probably stared blankly at that code for like 30 mins in a fatigued state before giving up and posting here yeah sorry i know this is supposed to be a safe space i wont say anything bad anymore
|
# ? Apr 28, 2015 19:53 |
|
gonadic io posted:don't use singly-linked lists for strings and you won't be bitten by this. i really really hate the fact that the good string type that uses arrays, "Data.Text", is in a library whereas the default "String" has absolutely horrendous performance and a whole load of gotchas like this but because it's easy to define* it's in the standard library yeah it's dumb and nobody that knows anything is using String for anything real
|
# ? Apr 28, 2015 19:54 |
|
i know i'm a terrible programmer but gently caress the web-based and timed coding challenge websites. they're a god drat blight
|
# ? Apr 28, 2015 19:58 |
|
fleshweasel posted:i guess the mongodb people were thinking of the word "humongous" when they made the name but somehow didn't realize that the rest of the world would think "mongoloid...wait wtf?"
|
# ? Apr 28, 2015 20:00 |
So while we are on the subject of Haskell folds, here's something I've never understood: why doesn't foldr space leak the way that foldl does? I've read both LYAH and RWH and I'm still really confused by that.
|
|
# ? Apr 28, 2015 20:03 |
|
gonadic io posted:(++) is perhaps the best example for lazy evaluation making it hard to reason about code. well, this is nothing to do with lazy evaluation. you'll see the same thing in even java when working with an immutable list data structure.
|
# ? Apr 28, 2015 20:10 |
|
VikingofRock posted:So while we are on the subject of Haskell folds, here's something I've never understood: why doesn't foldr space leak the way that foldl does? I've read both LYAH and RWH and I'm still really confused by that. doesnt it depend on the strictness of your arguments? like there's a reason you dontwalways choose foldr. the haskell wiki article explains it pretty nicely i think: https://wiki.haskell.org/Foldr_Foldl_Foldl%27 basically i think the idea is that if your function that consumes the input list can short circuit, then you're better off using foldr, but if it needs both arguments to compute a value then you're better off with foldl' code:
code:
i think.
|
# ? Apr 28, 2015 20:30 |
|
i dont know why foldl exists or at least why foldl' isn't the default one instead. it seems like any time you'd reach for foldl what you really want is foldl'
|
# ? Apr 28, 2015 20:32 |
|
crazypenguin posted:well, this is nothing to do with lazy evaluation. you'll see the same thing in even java when working with an immutable list data structure. wait, but in a lazy language wouldn't evaluating the first few elements of `xs ++ (ys ++ zs)' be pretty much instant since yz and zs won't be touched at all, whereas `(xs ++ ys) ++ zs' at least has to pass through n-1 appends, where there are n lists being appended? i suppose that won't make too much difference you're right, it's far more a consequence of immutability but the laziness does make it more pronounced i think VikingofRock posted:So while we are on the subject of Haskell folds, here's something I've never understood: why doesn't foldr space leak the way that foldl does? I've read both LYAH and RWH and I'm still really confused by that. this isn't quite the case, have a read of https://wiki.haskell.org/Foldr_Foldl_Foldl%27 and if you still have questions i'd be happy to answer them to directly answer your questions, foldl causes heap overflows and foldr causes stack overflows BUT foldr can produce its output incrementally whereas foldl has to produce it all in one go. for ints it's the same but for lists foldr can chug along bit-by-bit without necessarily consuming all the memory at once (it's very dependent on what you do with the result afterwards, and again, lazy evaluation means that maybe it'll be fast maybe it'll be slow who knows it depends on everything else) gonadic io fucked around with this message at 20:37 on Apr 28, 2015 |
# ? Apr 28, 2015 20:33 |
|
fart simpson posted:i dont know why foldl exists or at least why foldl' isn't the default one instead. it seems like any time you'd reach for foldl what you really want is foldl' gently caress, beaten also yes, i can't imagine a situation where you'd use foldl over foldl'
|
# ? Apr 28, 2015 20:37 |
|
fart simpson posted:so in that case foldl' is better because (+) can't short circuit and return a value early if it meets a certain condition. if instead of + you were using && or something, then you'd want the foldr way of doing things. this bit isn't right (heh) though, foldl will still short-circuit: code:
code:
gonadic io fucked around with this message at 21:09 on Apr 28, 2015 |
# ? Apr 28, 2015 20:44 |
|
gonadic io posted:wait, but in a lazy language wouldn't evaluating the first few elements of `xs ++ (ys ++ zs)' be pretty much instant since yz and zs won't be touched at all, whereas `(xs ++ ys) ++ zs' at least has to pass through n-1 appends, where there are n lists being appended? im new at this so maybe im wrong but i would say the problem is using a linked list as a string type. in a strict language the situation isnt much better, they'll both be pretty slow (the second one will still be slower i believe). i guess if you're going to blame laziness, its that it makes this scheme workable at all so long as you're careful, but as soon as you arent it becomes as slow as doing it strictly.
|
# ? Apr 28, 2015 21:08 |
|
HappyHippo posted:im new at this so maybe im wrong but i would say the problem is using a linked list as a string type. in a strict language the situation isnt much better, they'll both be pretty slow (the second one will still be slower i believe). i guess if you're going to blame laziness, its that it makes this scheme workable at all so long as you're careful, but as soon as you arent it becomes as slow as doing it strictly. this is exactly right
|
# ? Apr 28, 2015 21:09 |
|
also can't you avoid the whole problem by not using the parenthesis at all?
|
# ? Apr 28, 2015 21:12 |
|
gonadic io posted:(++) is perhaps the best example for lazy evaluation making it hard to reason about code. The ++ behaviour in Erlang is also right-associative, so that A ++ B ++ C goes and appends B ++ C then A ++ B and reduces the rewriting needed, but this cannot be expanded in the case of strict evaluation -- if the two append calls are separated by a function call, they'll always get the unoptimal (A ++ B) ++ Z equivalent. So if the Haskell version can't figure out a way to make this lazy (which somehow would be equivalent to body-recursion, I think), then their version is gonna be slowish like the Erlang one I guess.
|
# ? Apr 28, 2015 21:16 |
|
HappyHippo posted:im new at this so maybe im wrong but i would say the problem is using a linked list as a string type. in a strict language the situation isnt much better, they'll both be pretty slow (the second one will still be slower i believe). i guess if you're going to blame laziness, its that it makes this scheme workable at all so long as you're careful, but as soon as you arent it becomes as slow as doing it strictly. Erlang has both the linked-list-as-a-string and binaries-as-a-string (closer to a byte array, but mostly immutable). The way to work around it is with iolists, which more or less just let you nest lists arbitrarily (as in a tree of lists) to do append and prepend operations. Breaking up a list is still expensive by comparison but you could decide to go: code:
E: the cool thing about lists for text is really the ability to treat unicode grapheme clusters as single entities. So instead of [f, e, ^, t, e] to represent "fête", you could go [f, [e, ^], t, e] and handle everything as a unit again.
|
# ? Apr 28, 2015 21:43 |
|
MononcQc posted:The ++ behaviour in Erlang is also right-associative, so that A ++ B ++ C goes and appends B ++ C then A ++ B and reduces the rewriting needed, but this cannot be expanded in the case of strict evaluation -- if the two append calls are separated by a function call, they'll always get the unoptimal (A ++ B) ++ Z equivalent. Nah, this isn't a case of lazy doing something amazing, the compiler can't do any magic here. You're imagining lazy evaluation being able to come across a ((x ++ y) ++ z) mid-append and rewriting it to (x ++ (y ++ z)) I think? You need a special list type and append function to do that. And you can do that in a strict language, too, really. (Just saw your next post, that's basically this idea.) All gonadicio was getting at with laziness being "faster" is that if you access just the 'x' portion of ((x ++ y) ++ z) then that's only a constant factor slower than having some so for (x ++ (y ++ z)), so you haven't yet been exposed to the quadratic blow-up. Or at least, that's what I'm pretty sure they were getting at.
|
# ? Apr 28, 2015 21:45 |
|
kinda unrelated but is it just me or is the tooling around haskell pretty immature given how long the language has been around and how popular it is (relative to other small languages that is). seems like emacs is the standard choice for editor/ide, which is fine. haskell-mode itself is pretty good, but once you start looking for more (autocompletion, import suggestions, type info etc.) it gets pretty janky. ghc-mod seems like the most mature and useful choice but it's pretty janky, doesn't currently work with GHC 7.10 and/or cabal 1.18+ (which is whatever, 7.10 just came out but cabal 1.20 has been out for a year now and it's pretty pushy about upgrading) and is maintained by like, one guy who is in school and has no time to devote to it. beyond that is poo poo that's even older, even less active, or more immature. cabal itself also seems kinda janky. it has sandboxes which seem to work OK for the most part but the one time I tried to hack on a relatively non trivial it kinda blew up in ways that i'm too stupid and lazy to figure out. so what gives? do srs haskellers just not give a poo poo about bells and whistles? welp, I've got my syntax highlighting and i'm good to go!
|
# ? Apr 28, 2015 22:01 |
gonadic io posted:this isn't quite the case, have a read of https://wiki.haskell.org/Foldr_Foldl_Foldl%27 and if you still have questions i'd be happy to answer them That was a really good article, thanks. I think I understand it much better now. I've been thinking about making a CoC Haskell thread for a while now, to help with little questions like this. Would other people here have an interest in that? I don't really have a ton of experience writing practical Haskell so it feels a little weird for me to make the thread, but I'd definitely be willing to put in the time to make/maintain the OP if no one else wants to.
|
|
# ? Apr 28, 2015 22:02 |
|
rrrrrrrrrrrt posted:kinda unrelated but is it just me or is the tooling around haskell pretty immature given how long the language has been around and how popular it is (relative to other small languages that is). janky is the norm for small languages i'm thinking of erlang here
|
# ? Apr 28, 2015 22:13 |
|
gonadic io posted:It looks like there's some text missing in the definition of showParser, as there an infix operator (<|>) without anything to the right of it. That makes sense about Q1, I just got confused about what it was asking me to parse vs understanding the parser wrongly its a 4th year undergraduate class also, do you think my reasoning for Q2 was right? also anyone please feel free to call me out on being bad
|
# ? Apr 28, 2015 22:15 |
|
Notorious b.s.d. posted:janky is the norm for small languages i dunno, clojure made a lot of strides in the past 2-3 years and it's probably smaller than haskell. i mean, it helps that it runs on java, but there just seems to be more consolidation and momentum behind poo poo like cider, nrepl, lein, etc. than similar tools in the haskell world. those things are pretty slick these days. the intellij plugin for clojure is really, really good now too.
|
# ? Apr 28, 2015 22:25 |
|
you named the difference for yourself clojure and scala and so on could lean on java packaging and build mechanisms as long as they needed. you can happily build clojure with maven, and i believe lein uses ivy2 from java-land for all its dependency-related activities clojure also cheated on ide support. SLIME supported clojure basically from day one, because it was sufficiently lisp-like to support a port of swank, the SLIME server-side haskell and erlang have to do all this stuff from scratch
|
# ? Apr 28, 2015 22:30 |
|
VikingofRock posted:That was a really good article, thanks. I think I understand it much better now. there was a functional programming one before but it fell into archives as there just wasn't enough activity. i mean the only haskell that comes up in this thread is monthly valeyard's courseworks, weekly monad jokes and then the very occasional discussion like we had today, usually sparked by something that valeyard asks. feel free to make it i guess, i'd certainly be happy to answer questions in it. rrrrrrrrrrrt posted:kinda unrelated but is it just me or is the tooling around haskell pretty immature given how long the language has been around and how popular it is (relative to other small languages that is). it's not just you. i think part of it is its academic background. there's quite a few IDEs like leksah, an eclipse plugin and FP complete's web based one but none have really caught on. i myself just use sublime text, was reasonably happy using notepad++ and would use emacs if i could be bothered to learn it. honestly getting access to sublime's ctrl+b to build and run was an improvement over my previous workflow ("ghc Main.hs && Main.exe" in a command prompt) so perhaps i'm not the best person to ask about this! e: Valeyard posted:also, do you think my reasoning for Q2 was right? yep, as long as there's no missing part of the parser. basically if there were two parsers that started the same (for example records "Foo {fbar = bar, fbaz = baz}" vs non-record ADTs "Foo bar baz") then it's important to backtrack. luckily in the example given, non-record ADTs aren't represented and so there isn't an ambiguity between them and records, and you don't need "try". i initially got this question wrong as i assumed that you'd just accidentally not included part of the parser and that there was supposed to be a non-record ADT parser as part of it (which is presumably why the "try" was originally put in there in the first place) gonadic io fucked around with this message at 22:46 on Apr 28, 2015 |
# ? Apr 28, 2015 22:33 |
|
Notorious b.s.d. posted:you named the difference for yourself clojure totally ditched SLIME long ago tho. cider and nrepl were built from scratch and matured really quickly. i mean, immaturity of the tools is one thing, but there also seems to be no real momentum behind any one toolset or even a small subset of them or any desire to consolidate while the communities around other languages are very gung ho around tooling. i just get the impression that the community at large doesn't really give a gently caress so it makes me wonder what sort of workflow most people have.
|
# ? Apr 28, 2015 22:54 |
|
rrrrrrrrrrrt posted:kinda unrelated but is it just me or is the tooling around haskell pretty immature given how long the language has been around and how popular it is (relative to other small languages that is). you are definitely right. honestly the one thing i really wanted when trying haskell was to be able to hover over something and have my editor tell me its type, but all the existing solutions for this are incredibly finnicky about ghc-mod/cabal/whatever versions and never have up-to-date instructions about how to get it all set up right also cabal shits itself more often than it works ime, especially the dependency resolver. i dunno whether thats cabal's fault or package authors loving up their dependency specfications but its just another thing that ended up driving me away from haskell
|
# ? Apr 28, 2015 22:55 |
|
p.s. speaking of terrible people who are programmers, a friend just reminded me that this exists:
|
# ? Apr 28, 2015 22:56 |
|
it's linq it's reflection it's linq and reflection missing fields from joins in select statements? cryptic exceptions that don't tell you anything? Microsoft has got it all
|
# ? Apr 28, 2015 22:56 |
|
gonadic io posted:
sick. tbh emacs+haskell-mode+ghc-mod is a pretty good setup when it works. i'm mostly pissy because it's currently kind of fragile wrt ghc/cabal versioning and wasted a bunch of time loving around with it this weekend. when you dig into ghc-mod seems needlessly complex but i don't really know enough to know that for sure. i wanted to have a go at hacking the codebase a little but i kinda just spun around in circles and wrapping your head around a new, even mildly complex haskell codebase is a lot of work for someone as dumb and lazy as myself.
|
# ? Apr 28, 2015 23:00 |
|
someone rename this thread "haskell is terrible" please
|
# ? Apr 29, 2015 00:51 |
|
Bloody posted:someone rename this thread "haskell is terrible" please
|
# ? Apr 29, 2015 00:55 |
|
gonadic io posted:p.s. speaking of terrible people who are programmers, a friend just reminded me that this exists: his website is pretty great http://www.pjreddie.com/ see also, the original breathtaking resume http://www.pjreddie.com/static/Redmon%20Resume.pdf
|
# ? Apr 29, 2015 00:55 |
|
Haskell seems like a great way to feel smart when you take something easy and make it really hard and obtuse ... like my dick
|
# ? Apr 29, 2015 00:55 |
|
i do things at work that involve long lists of numbers and occasionally records constructed from these lists of numbers should i learn a haskell no
|
# ? Apr 29, 2015 00:58 |
|
Luigi Thirty posted:should i learn a haskell ft, fy unless you want to of course
|
# ? Apr 29, 2015 01:02 |
|
bobbilljim posted:
in which case your desires are incorrect
|
# ? Apr 29, 2015 01:03 |
|
|
# ? May 25, 2024 12:17 |
|
Bloody posted:someone rename this thread "haskell is terrible" please
|
# ? Apr 29, 2015 01:09 |