Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

MononcQc posted:

Almost every time you want to use an algorithm you know, you end up having to find a clever way to transform it to work a bit differently (or to invent your own variation of it) so that it meshes well with the stuff supported by your language and its constraints.

I did my dynamic programming homework in lisp today, because someone told me about an auto-memoization macro. It was the first time I've used lisp since I read a book about it like a decade ago.

Edit: Honestly the first thing that weirded me out about F# was immutability, but I understand what they're going for.

dougdrums fucked around with this message at 03:17 on Jul 21, 2015

Adbot
ADBOT LOVES YOU

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
How would you explain polymorphic lambda calculus well enough for another person to be able to derive typing judgements by hand? Let's say that this person is a Java programmer that is loosely familiar with prop logic. I can't do it without puking out formalisms or being too vague.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I can probably assume untyped. I'm trying to help a fellow student, but I took a bunch of logic courses so it's new to me also, but I wouldn't know what it would be like to start out by learning lambda calculus.

dougdrums fucked around with this message at 04:36 on Feb 19, 2016

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
The only pressing need is that we're taking it as a course. Regular human math is just nonsense to me and I just had to drop a course due to this, so I have a ton of sympathy for this fella who helped me in a previous math course but is finding lambda calculus to be absolutely opaque, and he isn't the only one. I had the idea of trying to write up a little crash course and a little index of notations with how their semantics work, try to approach it like programming a computer with funny symbols, but beyond, "follow the god drat simple rules, and if you gently caress up, which you will, do it again." I am at a loss, but I know this is exactly how my god drat math tutor feels and I know how it feels to look at a page of symbolism and go fuuuuuuuuk in my head.

We're starting to get into System F in class so I kinda wanted to make it as fast as possible. The most useful advice I seem to have given was, "imagine the term as a little computer program, what types would you assign the variables?" I mean, I don't think I really had an intuition for what domain and range were until I did the proofs (and it is mentioned in passing, confusing those who might not be so solid on functions in the first place), so it's hard for me to backtrack and approach it from the top-down, since I didn't even learn it that way. Really after writing this, I think the only way to learn is to do proofs and gently caress them up over and over again, but that seems like useless advice to give someone. I think I'll just have to let them struggle ... :-/

After learning all of that higher order stuff I love lambda calculus. It is so deceptively simple, and there are a ton of variations with interesting properties. It's just that fuckin learnin and teaching and learning in general is such a god drat frustrating exercise.

To keep this somewhat on topic: I understand Racket uses GNU Lightning, but I haven't done a lot of functional programming beyond F#. Generally speaking how does it compare in speed to other implementations?

Also I've never actually tried Haskell up until this moment, despite having read a poo poo-ton about it. http://tryhaskell.org/ output is great! Maybe I should just try to explain it using Haskell, duh!

dougdrums fucked around with this message at 01:34 on Feb 25, 2016

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I've been doing a lot of programming over RDP in lieu of using a VM. It's great because I can type make -j and then play video games.

Also if there's not a Visual Studio extension for whatever I'm trying to use, that's a pretty good cue to just do it on Linux instead of doing Windows rituals an unbound period of time.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Ok where do I get all of your neat editor things in VS2015? ^^^ those are some hot digraphs

F# for Fun and Profit is a great resource. The author of it somehow knows exactly what he can assume I already know, and then also what I want to know about F# as it relates to what I need to know .. if that was understandable ... he's good at instructional writing is what I mean.

EmmyOk posted:

At the moment it's really weird getting my head around using recursion to replace loops. Or I'll see a short code segment and spend a few hours trying to work out how it actually works.

I've written forth for a few things, and I feel like I became an able F# programmer once I realized that I am more or less writing backwards forth.

When I think about looping in a functional language, I think about lists. When I want a loop in an imperative program, I'm trying to apply a function or repeat a procedure until some condition breaks the loop. In F# this is usually just the end of the list you're working on.

I haven't had really any guidelines to go by. I don't know if I'm right or standard about anything, criticism is welcome, but with F# I take this approach:
- Arrange data into one or more fancy union type trees.
- Get my data into lists of whatever type.
- Parse the list using the hella sweet list matching, and maybe have some side-effects.
- Repeat ad absurdum.

Maybe it was because I learned F# to parse things (fparsec is soo good uuh), but I feel that with F#, with thanks to the type system and matching, everything can be approached as a parsing problem w/ side effects (is this what haskell users have been doing? wow whoa). I never use the built-in list operators in lieu of using recursive matching, because it's always clear to me what is going on in my program that way. I can break down every god drat branch my program makes if I please. My F# programs are all a series of 'type', 'let'/'let rec', 'and', 'do', with the occasional lazy keyword.

When you use recursion, you are literally creating a list; This is either as a transform of the list/tree of data you're working on, or you are generating a new list. Each called function appends its context or value after the callee's context, more or less. When the last call hits the condition that "breaks the loop", you have the choice of returning some aggregate value, or unrolling that chain of calls and returning a list.

I'm not much of a Java programmer, I think IIterable is the name of the interface in Java, but it's nearly the same (I don't think it's evaluated the same) approach as using C# IEnumerable, the Enumerable class methods, and the yield keyword, if that is helpful.

And of course, since lists and functions are first-class types, which can hold types of themselves as values, the purpose of your program is to cull the state of these things into a self-parsing well-trimmed n-ary tree that has the function you wanted.

I think that the 'trick', so to speak, is to treat your program like a stack of typed values/functions/lists, and to operate on that stack like you're making a little stack machine. By Currying, the only operation of this machine is to create one big function that will eventually be evaluated when you ask it nicely and feed it some data in the right order.

So really, instead of trying to cram all that typing info into your face, and remembering what level of indirection you've stumbled into, you only focus on the immediate area. The words, "I saw the angel in the marble and carved until I set him free" come to mind. Your job as an F# programmer is to cull state. In this awfully melodramatic analogy, the data is the marble and F# is your chisel. You just gotta chisel that data bit by bit until a statue comes out.

I'm not the best functional programmer; I'm going to have to be buried with a C compiler if my brain hasn't turned into one by then, but I've done some fancy low-level research/work on the topic ... I can go on but I'm a really terrible technical writer I think, and I'm not sure what I can speak openly about, but I think I can try to help fellow newbie F# programmers ...

dougdrums fucked around with this message at 22:54 on Jan 20, 2017

Adbot
ADBOT LOVES YOU

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

NihilCredo posted:

The code lens (automatic type annotations) in Ionide is amazing. I think it's the first feature it offers that simply can't be found in Visual Studio, and makes it a legit alternative even if you're running on Windows.
I still went back to VS because managing project files by hand (or with Forge's extremely limited commands) is godawful, and the .NET Standard thing has only made targeting even more of a clusterfuck.
I do use VS Code for writing .fsx scripts, though. I made a batteries-included folder that contains FSI.exe and all its required libraries, so I can just give scripts to colleagues without needing them to have anything installed.
All of the digraphs don't show up in VS2015, or I least I couldn't get them to ... in Code they work great though! I've been using Code on my linux laptop, for working on the run or when I'm waiting somewhere. It makes good use of screen space when I don't need a debugger or I am content with using gdb manually. Someone I work with made a more-or-less makefile using a fsx script, including building C libraries. It worked well and I thought it was a pretty good idea.

I find codelens to be annoying in VS (only because it messes up the spacing), but I do find myself hovering my mouse over definitions quite often ...

dougdrums fucked around with this message at 16:21 on Jan 21, 2017

  • Locked thread