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
bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
lol if you cant program by flipping a series of switches on a computer from memory, then you just cant program at all

Adbot
ADBOT LOVES YOU

orphean
Apr 27, 2007

beep boop bitches
my monads are fully functional

bobbilljim posted:

lol if you cant program by flipping a series of switches on a computer from memory, then you just cant program at all

If you aren't toggling the os into the supercomputer you built by hand from memory you ain't poo poo.



We are all scrubs in comparison

qntm
Jun 17, 2009

CPColin posted:

In interviews I've been in on, I've always been prepared to count an answer as correct if the person says, "I don't know, but I'd look here to find out."

Nobody ever does.

this is a relief because annoyingly the only sorting algorithms I can remember are the joke ones (bogosort, quantum bogosort, sleepsort, fonzsort)

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

qntm posted:

this is a relief because annoyingly the only sorting algorithms I can remember are the joke ones (bogosort, quantum bogosort, sleepsort, fonzsort)

remind me what quantum bogosort is

pseudorandom name
May 6, 2007

an O(n) implementation of bogosort on a quantum computer

Valeyard
Mar 30, 2012


Grimey Drawer
I must be missing something really obvious here, it's making GBS threads the bed because its expecting an Expr. but the function signature says to except a VarTable, which is defined as H.map String Expr - which is apparetnyl what the function is trying to return, if I am reading that right

code:
type VarTable = H.Map String [s]Expr[/s]

parse_par_decls :: [String] -> VarTable    
parse_par_decls par_lines = 
    do
        let k = [run_parser f95_par_decl_parser j | j <- par_lines]
        let kplus = [ pd_parval g | g <- k]
        let knames = [show (pd_parname t) | t <- k]
        let zipk = zip knames kplus
        let ma = H.fromList zipk
        return ma :: VarTable
which results in:

code:
Main.hs:63:16:
    Couldn't match expected type `Expr'
                with actual type `H.Map String Expr'
    In the first argument of `return', namely `ma'
    In a stmt of a 'do' block: return ma :: VarTable
edit:

ok I am 99% sure that I am actually somehow ending up trying to return
code:
H.Map String (H.Map String Expr)
which is why it is expecting an Expr

Valeyard fucked around with this message at 00:33 on Nov 20, 2014

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

pseudorandom name posted:

an O(n) implementation of bogosort on a quantum computer

hahahaha

gonadic io
Feb 16, 2011

>>=

this is a classic mistake and a good reason why 'return' should be called something different. to directly answer your question, you shouldn't use do-notation here, instead structure it like (you could also use "= let ... in ..." if you prefer)

code:
parse_par_decls par_lines = ma :: VarTable
    where
    k = ...
    kplus = ...
    ...
as for why, well do-notation is only to be used for monads and in it you don't deal with the objects themselves but the values inside of them*. for your code now, you're actually constructing the container yourself so you shouldn't use do-notation (or return). for now, probably the only monads that you'll use do-notation for will be IO and possibly list, maybe, state and stuff.

*: the 'a' inside of 'Parser a' for example, you never deconstruct Parsers but can only pass them around. you're free to gently caress around with the values of type 'a' as much as you want though.

gonadic io fucked around with this message at 00:41 on Nov 20, 2014

gonadic io
Feb 16, 2011

>>=
as for why you get that message, which Map are you using? it looks like it might have a monad instance, so the compiler is assuming that you're using do-notation correctly and inferring the type from that

Moist von Lipwig
Oct 28, 2006

by FactsAreUseless
Tortured By Flan

qntm posted:

this is a relief because annoyingly the only sorting algorithms I can remember are the joke ones (bogosort, quantum bogosort, sleepsort, fonzsort)

Hahaha what the hell is fonzsort? Does it involve jukebox punching?

Valeyard
Mar 30, 2012


Grimey Drawer

AlsoD posted:

this is a classic mistake and a good reason why 'return' should be called something different. to directly answer your question, you shouldn't use do-notation here, instead structure it like (you could also use "_lines = let ... in ma :: VarTable" if you prefer)

code:
parse_par_decls par_lines = ma :: VarTable
    where
    k = ...
    kplus = ...
as for why, well do-notation is only to be used for monads and you generally don't deal with the objects themselves but the values inside of them*. you're actually constructing the container yourself so you shouldn't use do-notation (or return).

*: the 'a' inside of 'Parser a' for example, you never deconstruct Parsers but can only pass them around.

arghh, I was tricked! the dummy skeleton code for this function had a dummy return statement, so I just assumed it would work that way without thinking about it

it is a Data.Map, which also came predefined.

if i had used the do notation correctly, would it have involved making the types explicit when doing "let"s?

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine
imo those list comprehensions are weird dude.

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

VLADIMIR GLUTEN posted:

Hahaha what the hell is fonzsort? Does it involve jukebox punching?

tongue punching in teh jukebox

gonadic io
Feb 16, 2011

>>=
i couldn't help myself, i did a little refactoring. you can replace zipk with a list comprehension and then inline kplus and knames to give:

code:
parse_par_decls par_lines = H.fromList [(show (pd_parname t), pd_parval t) | t <- k]
    where k = map (run_parser f95_par_decl_parser) par_lines
i mean you could easily inline k too but that line's already starting to look a little long

gonadic io
Feb 16, 2011

>>=

Valeyard posted:

if i had used the do notation correctly, would it have involved making the types explicit when doing "let"s?

replace "shouldn't" with "can't" in my previous statement. there is no correct way to use do-notation in this case. do-notation is sugar that makes it easier to work with monads, you're not working inside a monad here so you can't use do-notation. (but no, when using let statements inside do-notation you aren't forced to state all your types explicitly except in edge cases)

gonadic io fucked around with this message at 01:14 on Nov 20, 2014

Valeyard
Mar 30, 2012


Grimey Drawer

AlsoD posted:

there is no correct way to use do-notation in this case. do-notation is sugar that makes it easier to work with monads, you're not working inside a monad here so you can't use do-notation. (but no, when using let statements inside do-notation you aren't forced to state all your types explicitly except in edge cases)

i went back and looked at the monad section of learnyouahaskell and i see what you are saying there about monads (although most of that chapter is still daunting)


AlsoD posted:

i couldn't help myself, i did a little refactoring. you can replace zipk with a list comprehension and then inline kplus and knames to give:

code:
parse_par_decls par_lines = H.fromList [(show (pd_parname t), pd_parval t) | t <- k]
    where k = map (run_parser f95_par_decl_parser) par_lines
i mean you could easily inline k too but that line's already starting to look a little long

the question about this is; is it any more efficient? space wise, sure

gonadic io
Feb 16, 2011

>>=

Valeyard posted:

the question about this is; is it any more efficient? space wise, sure

probably not any faster (or less space) depending on how aggressively the compiler inlines/fuses. anybody else want to weigh in?

gonadic io
Feb 16, 2011

>>=
actually is there a fusion rule for 'zip'? it probably would end up faster then. either way, it won't be an appreciable difference and the refactoring would be for the person reading the code, whether it's future you or a marker

Stringent
Dec 22, 2004


image text goes here

Seaside Loafer posted:

Good examples:
1) I worked on an military aircraft simulator project and the brains of the simulator were in an ancient 6 foot tall computer less powefull that your phone probably that parts for were worth a fortune. Its code base was in FORTRAN. Now at first you might think 'fucks sake just convert it to something modern' but the problem is the amount of certification required to sign off a new codebase as functional for a goverment project, it requires massive amounts of testing and checking and certificates, especially with anything airplane related etc etc etc. It was a valid cost benifit analysis to keep this poo poo. So I know for a fact that a certain RAF base in the UK is running its simulator on 30 year old FORTRAN code on a computer that may well be older than some of you. Its not just a case of copying the code to a new language.

I understand needing to keep the software, but couldn't the hardware be virtualized?

DimpledChad
May 14, 2002
Rigging elections since '87.
hey guys lets talk about monads

Bloody
Mar 3, 2013

DimpledChad posted:

hey guys lets talk about gonads

DimpledChad
May 14, 2002
Rigging elections since '87.
that's a monads implementation in golang right

Valeyard
Mar 30, 2012


Grimey Drawer

DimpledChad posted:

hey guys lets talk about monads



"please work..."

gonadic io
Feb 16, 2011

>>=
as far as anybody who is programming haskell need be concerned, monad means 'can use do-notation on this thing'

DimpledChad
May 14, 2002
Rigging elections since '87.
b-b-but higher-kinded types functor transformation monad laws type theory burritos!

Seaside Loafer
Feb 7, 2012

Waiting for a train, I needed a shit. You won't bee-lieve what happened next

Stringent posted:

I understand needing to keep the software, but couldn't the hardware be virtualized?
That would be a good idea in theory but since nobody had already done it for the thing (wish I could remember what it was) the company couldnt really embark on a project to emulate it could they, that would have been more difficult than the actual project. If I get a brainwave and remember what model it was i'll post it. it was (is for another 5 years at least according to the contract) a 'mini-computer' haha, of some sort http://en.wikipedia.org/wiki/Minicomputer

Seaside Loafer fucked around with this message at 03:16 on Nov 20, 2014

Seaside Loafer
Feb 7, 2012

Waiting for a train, I needed a shit. You won't bee-lieve what happened next

e: quote is not edit

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
as an aside that job told me to redo the exercise and "go crazy" with it so I've made some horrific monstrosity in swing (which actually isn't that bad now that I've sit down with it for a few hours) that I'm getting happier with

ui programming is really a pain though.

gonadic io
Feb 16, 2011

>>=
"a picture is worth 1000 words" means that it takes 1k loving works to create a picture

Bloody
Mar 3, 2013

uncurable mlady posted:

as an aside that job told me to redo the exercise and "go crazy" with it so I've made some horrific monstrosity in swing (which actually isn't that bad now that I've sit down with it for a few hours) that I'm getting happier with

ui programming is really a pain though.

That is because you are not using c# and wpf

Valeyard
Mar 30, 2012


Grimey Drawer

Bloody posted:

That is because you are not using c# and wpf

or more specifically, its because he is using swing

Moist von Lipwig
Oct 28, 2006

by FactsAreUseless
Tortured By Flan

bobbilljim posted:

tongue punching in teh jukebox

text me

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Seaside Loafer posted:

Pick something you know a shitload about so you dont have to do any systems analysis and just try and write a program to do it. Every time I need to learn a new language I try to write this really complicated board game I played when I was a little kid, I never finish it but by the time im a quarter of the way through ive learnt enough of the language to be ok at it.

i think he's referring to the difficulty of jumping from one ecosystem to another like, professionally. learning the new ecosystem isn't the issue, it's doing something worthwhile that you can point to and say 'yes i am a professional user of this thing'

MeruFM
Jul 27, 2010
there's a heroku issue where a dyno could down and there's no notification so all requests going to that dyno just get stuck until the heroku timeout.

apparently this doesn't happen if you pay for the uber-dyno that costs like 10x as much. wtf

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

MeruFM posted:

there's a heroku issue where a dyno could down and there's no notification so all requests going to that dyno just get stuck until the heroku timeout.

apparently this doesn't happen if you pay for the uber-dyno that costs like 10x as much. wtf

didnt that happen like 2 years ago

Valeyard
Mar 30, 2012


Grimey Drawer
here is a more general haskell question, for which i am assuming the answer is no based on what ive read, but is there any kind of equivalent functionality of specifying a specific field in a datatype to be what is returned by show? I am trying to test something involving a really nasty data structure, and its reallllly hard to read whats happening, so i just want to get rid of most of the junk its showing me

attempting to install one of the pretty print libraries just now

Valeyard fucked around with this message at 05:08 on Nov 20, 2014

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison

Bloody posted:

That is because you are not using c# and wpf

im not familiar with c# as well as I am with Java, and the only PC I have access to is really bad and doesn't run VS so hot. Java it is~

Bloody
Mar 3, 2013

uncurable mlady posted:

im not familiar with c# as well as I am with Java, and the only PC I have access to is really bad and doesn't run VS so hot. Java it is~

You've chosen poorly

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison

Bloody posted:

You've chosen poorly

Mac OS X is the worlds best operation system

Adbot
ADBOT LOVES YOU

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine

Valeyard posted:

here is a more general haskell question, for which i am assuming the answer is no based on what ive read, but is there any kind of equivalent functionality of specifying a specific field in a datatype to be what is returned by show? I am trying to test something involving a really nasty data structure, and its reallllly hard to read whats happening, so i just want to get rid of most of the junk its showing me

attempting to install one of the pretty print libraries just now

are you defining the datatype? you can use record syntax to give your fields names.

  • Locked thread