|
Whoops I guess I didn't provide enough information. When checkS is called, it is called like this code:
|
# ? Nov 14, 2015 05:13 |
|
|
# ? May 15, 2024 04:33 |
|
Well, they're saying "add it to the list," but that's speaking in functional programmer codetalk for "put it in the list you return/pass to some other function."
|
# ? Nov 14, 2015 05:52 |
|
sarehu posted:Well, they're saying "add it to the list," but that's speaking in functional programmer codetalk for "put it in the list you return/pass to some other function." Okay but I'm still totally lost. here is what I have so far, which is wrong and broken code:
man I love/hate this class. I spend hours and hours trying to understand that idea that the assignments are trying to communicate, because I simply don't understand what they're asking me. When I understand what they are ask, implementing those ideas becomes trivial. On the last assignment I spend an hour talking with the TA just to determine that that yes, translating the psuedo-code into the abstract language was what we were supposed to do. It's like pulling teeth to get these guys who consider all this stuff second nature to just explain what they want so I can start thinking about the problem. edit: I am making progress, but I am still unsure how to handle the Seq case. Here is what I have now: code:
Snak fucked around with this message at 06:29 on Nov 14, 2015 |
# ? Nov 14, 2015 05:58 |
|
Snak posted:You can tell that it's wrong right away, because c is not a list. So the tail function obviously does not belong there. The recursion itself needs to be implemented in the Seq case, since that's the only place the code knows there's more than one statement. What are the actual semantics of NewInt? It looks to me like you might be overthinking it a little bit.
|
# ? Nov 14, 2015 13:33 |
|
The creator of Elm just did a talk sort of about the benefit of immutability that I found pretty interesting: https://www.youtube.com/watch?v=DfLvDFxcAIA
|
# ? Nov 14, 2015 14:45 |
|
Well I think I did get it all figured out last night. Thanks for the help. When I am stuck on a programming problem, I find that simply trying to explain the problem to other people often causes me to understand it better and make a breakthrough. Jabor posted:What are the actual semantics of NewInt? It looks to me like you might be overthinking it a little bit. Well NewInt isn't a function in Haskell, it's a statement in the abstract language that we have defined. Here is the language: code:
Here is the code that ended up working. I am not 100% sure that is correct, because I was down to the wire and figured it out with 15 minutes left on the deadline and it passed the obvious tests. code:
Snak fucked around with this message at 19:40 on Nov 14, 2015 |
# ? Nov 14, 2015 19:36 |
|
Snak posted:When I am stuck on a programming problem, I find that simply trying to explain the problem to other people often causes me to understand it better and make a breakthrough. https://en.wikipedia.org/wiki/Rubber_duck_debugging
|
# ? Nov 15, 2015 21:00 |
|
A couple of tips, for future reference:Snak posted:
You can write this as just x `elem` r. Snak posted:
If I'm not mistaken, this is a much simpler way to do the same thing: code:
|
# ? Nov 18, 2015 17:04 |
|
Elm 0.16 was just released. There's a blog post about it: http://elm-lang.org/blog/compilers-as-assistants The key feature is really the improved compiler error messages. I mean look at these, these are nice: There's also some improved speed in the generated JS, and TCE, etc who cares
|
# ? Nov 19, 2015 16:11 |
drat, those are some nice error messages.
|
|
# ? Nov 19, 2015 18:17 |
|
Those errors are very un-functional. Maybe I should try out elm.
|
# ? Nov 19, 2015 20:59 |
Is there an up-to-date tutorial on regexes in Haskell? It seems like every tutorial is out-of-date, and the documentation on Hackage is fairly lacking.
|
|
# ? Nov 19, 2015 22:55 |
|
VikingofRock posted:Is there an up-to-date tutorial on regexes in Haskell? It seems like every tutorial is out-of-date, and the documentation on Hackage is fairly lacking. Usually when you're not sure whether a library on Hackage is still "current" you can check whether the same library is available on Stackage, which is a stable set of Haskell packages that requires them to be maintained. From there we can find for example regex-compat, which seems to have a fairly simple interface. Consider the types of the functions as the documentation and view it a bit like a "type-puzzle" you are putting together. Example: code:
code:
|
# ? Nov 28, 2015 02:28 |
|
A guy did a good talk at Strange Loop that I just watched where he gives a really high level description of what it's like to actually use Elm. I liked the talk: https://www.youtube.com/watch?v=FV0DXNB94NE
|
# ? Dec 13, 2015 10:30 |
|
fart simpson posted:A guy did a good talk at Strange Loop that I just watched where he gives a really high level description of what it's like to actually use Elm. I liked the talk: Nice talk, it reminds of my first experience using F#: If it compiles it runs without errors. What a great feeling. I might have to try Elm.
|
# ? Dec 13, 2015 14:44 |
|
fart simpson posted:A guy did a good talk at Strange Loop that I just watched where he gives a really high level description of what it's like to actually use Elm. I liked the talk: The picture of O'Reilly's JavaScript next to java script: The Good Parts made me lol
|
# ? Dec 14, 2015 17:26 |
|
Munkeymon posted:The picture of O'Reilly's JavaScript next to java script: The Good Parts made me lol Me too, it is like 20% of the volume.
|
# ? Dec 14, 2015 18:22 |
|
I just took a trip down Elm memory lane. I've been messing around in Elm for over 2 and a half years now, and I just went back and updated one of my first projects that's still around on github with the bare minimum in updates so it will actually compile with the latest Elm version. It's kind of crazy how much Elm has grown in that time. Back then, everything was unorganized and nobody knew what they were doing or what coding style to use, so we were all 100% making it up as we went along. I was probably one of the only people that's used the experimental Automaton library, which is based on Arrowized Functional Reactive Programming. I used it to implement a kind of lazy rendering system that would do a cheap, quick state diff and only re-render different pieces of the UI if their relevant state had changed, then it would cache the output for the next tick. This is what it looked like: code:
code:
|
# ? Dec 17, 2015 17:35 |
|
Does anyone know of a racket function/macro that does something like these clojure operators? http://clojuredocs.org/clojure.core/-%3E http://clojuredocs.org/clojure.core/-%3E%3E The clojure docs use the word "thread" to describe the behavior, which is a good word to use except for the fact that there is another more common thing that uses that same word so its hard to search for. Backing up a sec -- what I want to do is use (make-immutable-hash) as a data structure to represent the memory in an mcu emulator. I'm using the immutable hash-table because I want to force it to be ~functional~. The code that actually implements the emulator doesn't need this kind of operator, but it would be helpful in setting up data for testing the implementation. Here's what I can do with what i know now Here's what I think might save me some I suspect that the -> operators only exist in Clojure to aide the usage of chaining method calls from java APIs, so maybe -> is unracketish. Any advice? ----- edit: I've tried doing a typed/required decl for hash-set* but I couldn't figure it out. hash-set* does what I want to do but I don't know how to write the contract for it. ----- Update, I think I can write a macro to expand it to this, Lisp code:
Solved it with a plain old function. Posting it here for anyone who is interested, including myself 4 weeks from now when i forget what i was thinking. Lisp code:
Jerry Bindle fucked around with this message at 21:10 on Dec 17, 2015 |
# ? Dec 17, 2015 18:06 |
|
Your Elm posts always make me want to do more with Elm. I've done a little, but not enough.
|
# ? Dec 17, 2015 18:09 |
Barnyard Protein posted:Your Elm posts always make me want to do more with Elm. I've done a little, but not enough. Same here. I've never really had any desire to do web stuff, but fart simpson's elm posts make it look so slick.
|
|
# ? Dec 17, 2015 18:49 |
|
For fun, that Automaton lazy renderer ended up being used for this: http://beer.deadfoxygrandpa.xyz. This was before Elm had the elm-html package, so all the graphics were done in a kind of weird but cool abstraction layer that didn't give you any access at all to normal HTML or CSS stuff.
|
# ? Dec 17, 2015 19:13 |
|
VikingofRock posted:Same here. I've never really had any desire to do web stuff, but fart simpson's elm posts make it look so slick. As long as you stick to Elm's primary use case (UI FRP), then most of your code will look slick. We used elm-svg to make cool data visualizations with animations and all the jazz that people would normally use D3.js for, but without the lovely selector-based programming that the D3 API requires.
|
# ? Dec 17, 2015 21:22 |
|
Barnyard Protein posted:Does anyone know of a racket function/macro that does something like these clojure operators? There is no built in macro that does this in Racket, but I know at least one library that provides it, Rackjure http://www.greghendershott.com/rackjure/index.html#%28part._.Threading_macros%29
|
# ? Dec 19, 2015 10:12 |
|
GHC 8.0 release candidate is around the corner, including cool stuff like -XTypeInType (blog post about it), Strict Haskell, Duplicate Record Fields (allows you to have record field names where the ambiguity is resolved during typechecking) and a whole lot of other stuff.
|
# ? Dec 19, 2015 14:26 |
|
Votlook posted:There is no built in macro that does this in Racket, but I know at least one library that provides it, Rackjure Awesome, thank you!
|
# ? Dec 20, 2015 06:32 |
|
So I'm going through a phase of being ridiculously sold on Elm and wanting to try something non trivial in it. Seriously watch Evan's Lets be Mainstream talk, it's amazing to see a young language in the front end with responsible management, ensuring you can actually rely on packages, coding style, etc etc. The foundation of the elm architecture is great too. I had one question though that maybe fart simpson could help me with. With the StartApp package it has a way to send in inputs and map them to actions for the model. Do components have any way to request Signals themselves, as I can see cases where you'd have say a Draggable component, and that'd like to listen to the Mouse.position signal once you start dragging, or a timer listening to (Time.every Time.millisecond). All that said though, the animation example nearly gets there with Effects.tick. You're element is always going to know whether it needs to be reading from a signal, with a Draggable it would have a state of Dragging so it knows to trigger an effect at that point, so I guess all I'd be looking for is a way to make a Signal be polled by a Task that you can map into an effect. Does this seem reasonable? If it's at all possible to collect from a Signal with a task then you can keep the Static Signals, yet only be turning them into actions when actually required, keeping the possible complications down of polling say the Mouse position continuously. I guess what I'm looking for is just something that can do (Signal a -> Task Never a) and then if be golden. Elm could do with a Hoogle-like.
|
# ? Dec 20, 2015 09:33 |
|
I'm curious about people's experiences using Elm to develop a traditional website versus a 'web app', in terms of stuff like URLs and just general advice.
|
# ? Dec 21, 2015 02:18 |
|
I tried using elm on a little scheduling pet project and could not find a decent way to get around basic routing. I think it really shines on fancy single page web apps.
|
# ? Dec 21, 2015 06:49 |
|
By the looks of it it's just missing a decent package. Routing in web apps is pretty straightforward if you know how to go about it, with something that can map paths to a Route Type with parameters. You'd need to write Native bindings to do it properly in Elm though, so you can bind to the various page change events.
|
# ? Dec 21, 2015 07:01 |
|
Visible type application might make it into GHC 8.0, allowing you to write things likecode:
code:
|
# ? Dec 22, 2015 05:04 |
|
Barnyard Protein posted:Does anyone know of a racket function/macro that does something like these clojure operators? Out of boredom I took a stab at implementing thread-first as a function. I got close, but don't know much about rackets quoting/unquoting, so the syntax is dumb. I also don't have racket installed, so I'm using try-racket.org and I want to stab my hands to death. Lisp code:
|
# ? Dec 22, 2015 23:09 |
|
I'm loving around in Elm and trying to do the exercises in http://elm-lang.org/examples/binary-tree For #2 I tried to do code:
|
# ? Dec 30, 2015 21:38 |
|
I don't know Elm but I'll bet you a zillion bucks it's that the type of "::" is a -> List a -> List a and also by the way it's probably right-associative. flatten left returns a List a, and (value :: flatten right) evaluates to a List a. You need to append the lists using an append function, you're trying to cons them together. Edit: Edited to pretend more convincingly that I didn't check the Elm docs before writing parts of this reply.
|
# ? Dec 30, 2015 21:44 |
|
Yep, that's it. I thought I was being all clever there by avoiding implicitly creating a bunch of basically-useless single-element lists.
|
# ? Dec 30, 2015 22:28 |
Munkeymon posted:Yep, that's it. I thought I was being all clever there by avoiding implicitly creating a bunch of basically-useless single-element lists. I think that would get compiled away anyways, but if not I think this would work: code:
VikingofRock fucked around with this message at 23:52 on Dec 30, 2015 |
|
# ? Dec 30, 2015 23:44 |
|
VikingofRock posted:I think that would get compiled away anyways, but if not I think this would work: Yep, that works without the parens. Meantime, my dumbass attempts at writing fold are crashing their compiler service
|
# ? Dec 31, 2015 00:05 |
|
I was pretty sold on Elm, until I started to try and actually write stuff. I really hate the stupid "no typeclasses, if you really need it just pass an explicit record around!" poo poo. It's a functional language, it'll mostly be used by people that understand it, and if you don't dive right into monad bullshit, it's a pretty simple concept. I don't think that you should be programming if you can't understand the concept of a constraint.
|
# ? Dec 31, 2015 00:08 |
|
Sinestro posted:I was pretty sold on Elm, until I started to try and actually write stuff. I really hate the stupid "no typeclasses, if you really need it just pass an explicit record around!" poo poo. It's a functional language, it'll mostly be used by people that understand it, and if you don't dive right into monad bullshit, it's a pretty simple concept. I don't think that you should be programming if you can't understand the concept of a constraint. Agreed. I also think the whole "no monads!!!" thing itself is pretty silly. They've reimplemented Applicative like half a dozen times in the core libraries, its ridiculous that there's so many versions of map/map2/map3/... when they could just define them once and be done with it. Is this because typeclasses are difficult to implement, or is this from the "for your own good" school of language design? Or are they just concerned that people will be turned off the language if it has monads in it?
|
# ? Dec 31, 2015 02:14 |
|
|
# ? May 15, 2024 04:33 |
|
If you're making an interesting programming language these days it's become a requirement to scare off the functional programming morons. Avoiding type classes helps them establish their market position.
|
# ? Dec 31, 2015 02:33 |