« first day (1687 days earlier)      last day (135 days later) » 

7:46 AM
@Razetime show is a function that's defined for one typeclass, Show :)
 
 
2 hours later…
10:21 AM
@UnrelatedString i should avoid talking about haskell like i know it well
 
i'm just being snarky because you happened to choose exactly the wrong word
i think typeclass is roughly synonymous with type and/or class in some other languages
but yeah, show :: (Show a) => a -> String, and various standard types have Show instances
 
hey look this room is alive
 
it's also a typeclass that you can derive for your own types if you want to be able to show them but don't feel like writing show for them
 
@UnrelatedString well it is a good thing. I need to use haskell more (it has been painful so far)
 
depending on what for, it will either get much better or much worse
 
10:37 AM
I had no ideas, so i went over to GSoC and found a Websockets app project. Dunno if i'll get it
@UnrelatedString what do you recommend as a starter app? I tried an IRC bot
it is uhh something
 
i haven't the faintest clue
if you can't tell my single attempt at building something large in haskell is going a bit slow :)
 
what is the single attempt
 

 This Might Be a Room

Discussion about the Perhaps golfing language github.com/Unrel...
 
aht his one
but it also needs ideas
not just raw haskell knowledge
 
10:57 AM
yeah
so for the irc bot i assume you've found some kind of library for it?
 
11:13 AM
Haskell?
hmm
 
@UnrelatedString nah i found a wiki article
and IRC isn't really that hard
 
i saw this
and i saw haskell elsewhere
any tips for larning it?
 
well, go over to exercism and start solving some things. Learn you a haskell is a decent intro
 
where?
 
has a lot of good exercises, explanations, guides, willing mentors
 
11:18 AM
OK thnx
 
i think exercism might be where i started too actually
@Razetime curious as to how much you've accomplished then
i think i couldn't write an irc bot in python without a dedicated library
 
really? IRC protocol is quite simple
and the wiki page is quite descriptive on what you gotta do
 
i see the word "protocol" and my brain just shuts down
 
hehe trust me you can do it quite easily if you read the tutorial
 
i barely even know what to do with file descriptors on my own machine
also wow has exercism overhauled the entire platform and ui again already
because i know they were talking about v3 but this does not look like v3
 
11:23 AM
exercism is quite cool
 
ooh they added built in tracking for your pull requests
forgot how many people starred this abomination
 
@UnrelatedString ok
I don't see why this is bad
module Temperature (tempToC, tempToF) where

{- Implement the function `tempToC` to convert
`  Fahrenheit to Celsius                    -}

tempToC x=(x- 32) / 1.8.

{- Implement the function `tempToF` to convert
`  Celsius to Fahrenheit                    -}

tempToF x=x* 1.8 + 32.
oh i know
why is this bad also?
module Temperature (tempToC, tempToF) where
tempToC x=ceiling ((x- 32) / 1.8)
tempToF x=x* 1.8 + 32
@UnrelatedString
 
11:58 AM
@NumberBasher That compiles fine for me.
 
[1 of 2] Compiling Paths_temperature
[2 of 2] Compiling Temperature

/mnt/exercism-iteration/src/Temperature.hs:2:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
tempToC :: (RealFrac a, Integral b) => a -> b
|
2 | tempToC x=ceiling ((x- 32) / 1.8)
| ^^^^^^^

/mnt/exercism-iteration/src/Temperature.hs:3:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
tempToF :: Fractional a => a -> a
|
3 | tempToF x=x* 1.8 + 32
| ^^^^^^^
Preprocessing test suite 'test' for temperature-1.0.0.0..
> >>> 12894712893012**1294871209382
> Infinity
That's not as good as Python
;-)
> >>> 2**10
> 1024.0
This took me by surprise -- Why the .0?
 
The problem is in your test not the code you posted.
There are also some warnings, which you probably want to resolve but that don't actually block development.
 
what problem is there? thnx
 
If you resolve the types the error in your tests should probably present itself.
The warnings are because the functions tempToC and tempToF don't have type signatures.
The compiler can figure things out when things are good, but if you tell the compiler what types you expect then it gives more useful errors when things go wrong.
 
how do i go back to the script exercium gave me?
Oh I got it
h m m
module Temperature (tempToC, tempToF) where

{- Implement the function `tempToC` to convert
`  Fahrenheit to Celsius                    -}

tempToC :: Integer -> Float
tempToC x = ((x- 32) / 1.8)


{- Implement the function `tempToF` to convert
`  Celsius to Fahrenheit                    -}

tempToF :: Float -> Integer
tempToF x = ceiling((x* 1.8 + 32))
[1 of 2] Compiling Paths_temperature
[2 of 2] Compiling Temperature

/mnt/exercism-iteration/src/Temperature.hs:7:14: error:
    • Couldn't match expected type ‘Float’ with actual type ‘Integer’
    • In the expression: ((x - 32) / 1.8)
      In an equation for ‘tempToC’: tempToC x = ((x - 32) / 1.8)
  |
7 | tempToC x = ((x- 32) / 1.8)
  |              ^^^^^^^^^^^^^

--  While building package temperature-1.0.0.0 (scroll up to its section to see the error) using:
      /opt/test-runner/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.4 --builddir=.stack-work/
Don't understand...
(make sure you ping me in your reply thnx
 
12:10 PM
(-) :: Num a => a -> a -> a
(/) :: Fractional a => a -> a -> a
@NumberBasher These are the two functions you use. Do you know how to read their types?
 
erm well no
 
Ok no problem let me explain them.
 
what did i lose in the tutorial
 
(-) takes two numbers of the same type and produces another number of that type (by subtracting). (/) takes two fractionals of the same type and produces another fractional of that type.
 
yah
that's true for most langs...
even tho i don't why
(-) :: Num a => a -> a -> a
(/) :: Fractional a => a -> a -> a
means that
 
12:13 PM
So you say your code takes an integer and produces a float, but both (-) and (/) produce results with the same type as their input.
 
so i need to float it?
 
Yes.
Don't worry too much about being able to read the types right now, you will learn.
 
7 | tempToC x = ((x- 32.0) / 1.8)
  |              ^^^^^^^^^^^^^^^
Why?
 
The x is still an Integer, since your type signature says so 32 was not the issue.
 tempToC x = (fromInteger x - 32) / 1.8
 
oh
why does this not work
((x- 32.0) / 1.8)
still an int?
 
12:17 PM
It does work.
It just doesn't work with your type signature.
 
Hmm...
Golfing must be hard
 
Golfing is fun and not very hard.
But dealing with floats is often a bit annoying.
 
is there a shorter way
fromIntegral will else take about 20% of the answer
 
Yeah, fromInteger is 1 byte shorter but not all that much better.
The solution would be try to take a float instead since that's the type we want to output.
But it's not always possible.
 
i just typed this
isLeapYear x = not x%4and x%100or not x%400
i'm so stupid
hahaha
 
12:22 PM
Modulo is the mod function. And there are no implicit type conversions.
 
oh no
let's hope this ugly rubbish works
isLeapYear x = not fromIntegral mod x 4 && fromIntegral mod x 100 || not fromIntegral mod x 400
 
Definitely not.
Your operator precedence is pretty messed up, and fromIntegral is not going to cast to Bool.
 
oh no
[1 of 2] Compiling LeapYear

/mnt/exercism-iteration/src/LeapYear.hs:4:16: error:
• Couldn't match expected type ‘(Integer -> Integer -> Integer)
-> Integer -> Integer -> Bool’
with actual type ‘Bool’
• The function ‘not’ is applied to four arguments,
but its type ‘Bool -> Bool’ has only one
In the first argument of ‘(&&)’, namely ‘not fromIntegral mod x 4’
In the first argument of ‘(||)’, namely
‘not fromIntegral mod x 4 && fromIntegral mod x 100’
|
4 | isLeapYear x = not fromIntegral mod x 4 && fromIntegral mod x 100 || not fromIntegral mod x 400
Given a year, report if it is a leap year.

The tricky thing here is that a leap year in the Gregorian calendar occurs:

on every year that is evenly divisible by 4
except every year that is evenly divisible by 100
unless the year is also evenly divisible by 400
 
Instead just say what you want without any dirty hacks. mod x 4 == 0
 
How do I do this?
 
12:25 PM
isLeapYear x = (mod x 4 == 0) && (mod x 100 /= 0) || (mod x 400 == 0)
 
ghci> 5 /= 5
False
both works?
/=, !
!=
 
No just /=
 
i would much rather not it
 
Ok, I'm not sure why but you can do that.
 
because != /= everything confusing
i suppose you don't have += like in Pyothon?
 
12:29 PM
Thank god no.
in The Nineteenth Byte, Mar 12, 2017 at 19:06, by Wheat Wizard
CMC: Without running it, guess what this python snippet prints.
a=[1,2,3]
a[-1]+=a.pop()
print a
Haskell doesn't have mutable state so it avoids stuff like +=.
 
@WheatWizard i suppose that is python2?
 
Yes, but you can add parentheses and it does the same thing in Python 3 as well.
 
>>> a=[1,2,3]
>>> a[-1]+=a.pop()
>>> print a
[1, 6]
why?
i think i understand
based on this
>>> a=[1,2,3]
>>> a[-1]=a[-1]+a.pop()
>>> a
[1, 6]
>>>
>>> a=[1,2,3]
>>> a[-1]=a.pop()+a[-1]
>>> a
[1, 5]
 
Yeah.
 
> Given an age in seconds, calculate how old someone would be on:

Mercury: orbital period 0.2408467 Earth years
Venus: orbital period 0.61519726 Earth years
Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds
Mars: orbital period 1.8808158 Earth years
Jupiter: orbital period 11.862615 Earth years
Saturn: orbital period 29.447498 Earth years
Uranus: orbital period 84.016846 Earth years
Neptune: orbital period 164.79132 Earth years
I don't understand the input method
 
12:38 PM
hm. Hard to tell, maybe it's an integer.
 
so it gets a[-1] which is 3 and then pops it which is 3 again, adds it to get 6, and then now a is [1,2] and now we set a[-1]=6 which makes it [1,6] ok makes sense
> Instructions
Given an age in seconds, calculate how old someone would be on:

Mercury: orbital period 0.2408467 Earth years
Venus: orbital period 0.61519726 Earth years
Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds
Mars: orbital period 1.8808158 Earth years
Jupiter: orbital period 11.862615 Earth years
Saturn: orbital period 29.447498 Earth years
Uranus: orbital period 84.016846 Earth years
Neptune: orbital period 164.79132 Earth years
So if you were told someone were 1,000,000,000 seconds old, you should be able to say that they're 31.69 Earth-years old.
module SpaceAge (Planet(..), ageOn) where

data Planet = Mercury
            | Venus
            | Earth
            | Mars
            | Jupiter
            | Saturn
            | Uranus
            | Neptune

ageOn :: Planet -> Float -> Float
ageOn planet seconds = error "You need to implement this function."
 
Ok so it's a number years maybe?
 
ageOn planet seconds = planet * seconds?
• Couldn't match expected type ‘Planet’ with actual type ‘Float’
• In the second argument of ‘(*)’, namely ‘seconds’
In the expression: planet * seconds
In an equation for ‘ageOn’: ageOn planet seconds = planet * seconds
|
13 | ageOn planet seconds = planet * seconds
| ^^^^^^^

-- While building package space-age-1.2.0.6 (scroll up to its section to see the error) using:
/opt/test-runner/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.4 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0 build lib:space-age test:tes
ohh great. sarcasm
i mean
 
Do you understand the error?
 
no
but i think it tells me he can't * a planet
 
12:44 PM
Yes, you can only multiply two things of the same type (they also have to be numbers).
Planets are not numbers so you can't use (*) on them.
Do you know how to do pattern matching?
 
then how?
no...?
 
ageOn :: Planet -> Float -> Float
ageOn Jupiter earthAge = 2.3 * earthAge
ageOn Mars earthAge = 4.3 * earthAge
ageOn Venus earthAge = 9.5 * earthAge
...
You can define different cases of your function each on their own line.
 
ok thanks
why?
wieuhiehjdisjowhuiewhiwco$ ghci
-bash: ghci: command not found
i just installed it, it works
and then i restart the terminal
why
sudo: apt-get: command not found
what
 
hmmm
 
i have a macos fyi
 
12:51 PM
Ah.
why are you running apt-get?
 
when i first installed if i used
curl --proto '=https' --tlsv1.2 -sSf get-ghcup.haskell.org | sh
 
Ah well yeah that shell script is probably for linux.
 
brew install might work *praying
 
It should.
 
@WheatWizard yep
not working is the whole point of programming
(not)
@WheatWizard 25% now
50%...
75%...
pouring...
c u tmr (my tmr is in china
now it works!!! @WheatWizard
 
1:07 PM
Nice.
 
1:50 PM
back
i wrote this
ageOn Mercury Earthyears=0.2408467 * Earthyears
ageOn Venus Earthyears=0.61519726 * Earthyears
ageOn Earth Earthyears=1.0 * Earthyears
ageOn Mars Earthyears=1.8808158 * Earthyears
ageOn Jupiter Earthyears=11.862615 * Earthyears
ageOn Saturn Earthyears=29.447498 * Earthyears
ageOn Uranus Earthyears=84.016846 * Earthyears
ageOn Neptune Earthyears=164.79132 * Earthyears
i think it is unallowed to use Earthyears as the variable name
wrote this
ageOn :: Planet -> Float -> Float
ageOn Mercury years=0.2408467 * years
ageOn Venus years=0.61519726 * years
ageOn Earth years=years
ageOn Mars years=1.8808158 * years
ageOn Jupiter years=11.862615 * years
ageOn Saturn years=29.447498 * years
ageOn Uranus years=84.016846 * years
ageOn Neptune years=164.79132 * years
told me this
space-age> test (suite: test)


ageOn
  Earth FAILED [1]

Failures:

  test/Tests.hs:27:26:
  1) ageOn Earth
       expected: 31.69
        but got: 1.0e9

  To rerun use: --match "/ageOn/Earth/"

Randomized with seed 585517182

Finished in 0.0003 seconds
1 example, 1 failure

space-age> Test suite test failed
Completed 2 action(s).
Test suite failure for package space-age-1.2.0.6
    test:  exited with: ExitFailure 1
Logs printed to console
why?
@WheatWizard
oh
> Given an age in seconds
ageOn :: Planet -> Float -> Float
ageOn Mercury years= years/0.2408467           /60/60/24/365.25
ageOn Venus years=1/0.61519726 * years        /60/60/24/365.25
ageOn Earth years=years                      /60/60/24/365.25
ageOn Mars years=1/1.8808158 * years        /60/60/24/365.25
ageOn Jupiter years=1/11.862615 * years    /60/60/24/365.25
ageOn Saturn years=1/29.447498 * years    /60/60/24/365.25
ageOn Uranus years=1/84.016846 * years   /60/60/24/365.25
ageOn Neptune years=1/164.79132 * years /60/60/24/365.25
This did it
yay
I just found this
ageOn :: Planet -> Float -> Float
13
ageOn p s = s / (31557600.0 * planetMultiplier)
14
  where
15
    planetMultiplier = case p of
16
      Earth   ->   1.0
17
      Mercury ->   0.2408467
18
      Venus   ->   0.61519726
19
      Mars    ->   1.8808158
20
      Jupiter ->  11.862615
21
      Saturn  ->  29.447498
22
      Uranus  ->  84.016846
23
      Neptune -> 164.79132
condiserably better
let's put this there actually
bye for now
 

« first day (1687 days earlier)      last day (135 days later) »