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
Dominoes
Sep 20, 2007

Is learning Haskell intended to be an order of magnitude more difficult than other programming languages?

Adbot
ADBOT LOVES YOU

Dominoes
Sep 20, 2007

I might try again with another resources. I used LYAH, and it felt more like documentation of every part of the standard library than a tutorial. Something that teaches how to build simple, useful programs using basic features would have been more helpful.

Dominoes
Sep 20, 2007

Hey dudes, Haskell's complaining that none of my variables are in scope. What's up? It does the same when using where in place of let, or 'a' syntax in the type sig.

code:
vap_pres_sat :: Float -> Float
vap_pres_sat temp =
    let T = temp + 273.15  -- Temperature in K
        Tc = 647.096  -- Critical temperature, in K
        Pc = 220640  -- Critical pressure in hPa
        C1 = -7.85951783
        C2 = 1.84408259
        C3 = -11.7866497
        C4 = 22.6807411
        C5 = -15.9618719
        C6 = 1.80122502
        e = 2.71828

        v = 1 - (T / Tc)
    in  e^((Tc / T) * (C1*v + C2*v^1.5 + C3*v^3 + C4*v^3.5 + C5*v^4 + C6*v^7.5)) * Pc

Dominoes fucked around with this message at 07:11 on Jun 21, 2015

Dominoes
Sep 20, 2007

Thank you for the detailed explanation. It makes sense, and solves the issue I posted. I'm running into a second issue with the code I posted above, after fixing the variable names:

quote:

No instance for (Integral Float) arising from a use of `^'
Possible fix: add an instance declaration for (Integral Float)
In the first argument of `(*)', namely

The nature of the error changes a bit if I change the type signature, but I can't sort it out. It's specifically pointing to my variable e. Note that this is a variable defined within the let, while the type signature should, AFAIK, just deal with input and output variables, which are both floats.

Dominoes fucked around with this message at 08:27 on Jun 21, 2015

Dominoes
Sep 20, 2007

Thank you. That explanation makes sense, and my code works now.

Adbot
ADBOT LOVES YOU

Dominoes
Sep 20, 2007

lol

  • Locked thread