qmm 2017-01-31 13:45:37
a = [188.38354691296536,180.9969223840326,173.89993154565036,167.08121769837453,160.5298694453072,154.23540323155294,148.187746568276,142.3772219145808,136.79453119137543,131.43074090246682]
qmm 2017-01-31 13:45:41
sum a / length a
qmm 2017-01-31 13:45:50
i would like to know how to do something like this...
qmm 2017-01-31 13:46:15
toInteger (sum a) / realToFrac $ length sum
glguy 2017-01-31 13:46:43
sum a / fromIntegral (length a)
qmm 2017-01-31 13:47:01
(sum a) :: Fractional a => a
qmm 2017-01-31 13:47:24
ah, i did the exact opposite
qmm 2017-01-31 13:47:36
fromIntegral $ sum a / length a
qmm 2017-01-31 13:48:18
Could not deduce (Foldable ((->) (t0 a0)))
qmm 2017-01-31 13:48:19
arising from a use of 'length'
qmm 2017-01-31 13:48:28
from the context: Fractional a
qmm 2017-01-31 13:48:38
bound by the inferred type of it :: Fractional a => a
qmm 2017-01-31 13:48:48
oh, right a pastebin, sorry
glguy 2017-01-31 13:48:51
qmm: That's because you wrote: length sum
qmm 2017-01-31 13:49:06
doh!
qmm 2017-01-31 13:51:17
glguy: i really appreciate you helping me. i now feel so embarassed, i will have to study https://wiki.haskell.org/Converting_numbers
Taslem 2017-01-31 13:54:05
I'm running into an incomprehensible error for what I think is a relatively simple use-case for GADTs:
Taslem 2017-01-31 13:54:07
http://lpaste.net/351841
Taslem 2017-01-31 13:54:30
(I'm using GHC 7.8.3 for the record)
Taslem 2017-01-31 13:55:29
The gist is that I want a length-encoded result list with a different type of element than the input to a certain function; but ghc explodes when I try to pattern match on the result, even though it knows what type it is
glguy 2017-01-31 13:56:45
Taslem: Add a type signature to example'
Taslem 2017-01-31 13:57:22
@glguy Wow, thanks. Why didn't ghc infer it as Bool?
lambdabot 2017-01-31 13:57:22
Unknown command, try @list
glguy 2017-01-31 13:57:53
Taslem: Because you're on an outdated GHC
Taslem 2017-01-31 13:58:12
Well that's simple. Thanks!
glguy 2017-01-31 13:59:00
pattern matching on GADTs tends to require explicit type signatures because of the restrictions around information flow of type information
glguy 2017-01-31 13:59:29
and it's an area that GHC is getting smarter about over time
Taslem 2017-01-31 13:59:40
I see. Does current GHC need a signature there?
glguy 2017-01-31 13:59:44
no
barryburd 2017-01-31 14:19:49
Dumb question alert!! I've defined k = (1, 2, "xyz") When I do :type k, the result is (num t1, Num t) => (t, t1, [Char]) Why isn't the result (Num, Num, [Char]) and why isn't the result (Num t1, Num t, Num t2) => )[t, t1, [t2]) ?
Welkin 2017-01-31 14:22:02
Num is not a type
Welkin 2017-01-31 14:22:05
it is a typeclass
Boomerang 2017-01-31 14:22:13
barryburd: Num is a type class, when on the left of => it is a constraint on t and t1. For example t and t1 could be Int, Float...
barryburd 2017-01-31 14:22:36
Type vs. typeclass. Thank you.
Boomerang 2017-01-31 14:23:29
barryburd: In your second example it cannot be [t2] because Char don't have a Num instance
barryburd 2017-01-31 14:24:23
Yeh, I meant (Num t1, Num t, Char t2), but I see why that wouldn't work.
Boomerang 2017-01-31 14:25:41
Right, haskell doesn't infer that 1 and 2 are Ints but rather that they have a Num instance, this way they could be Int, Float, Double or other depending on the use case
barryburd 2017-01-31 14:26:17
Thank you.
Welkin 2017-01-31 14:29:41
hi zipper
Welkin 2017-01-31 14:29:49
are you building anything lately?
noan 2017-01-31 14:35:03
is there a stack command to build and run on file change?
Koterpillar 2017-01-31 14:37:19
noan: --file-watch
noan 2017-01-31 14:38:51
Koterpillar, is there a way to compose that will run? sorry, very new to stack and coming from sbt
Koterpillar 2017-01-31 14:39:05
noan: stack build --file-watch --exec ...
noan 2017-01-31 14:39:19
ah thanks
Welkin 2017-01-31 14:40:06
sbt?
noan 2017-01-31 14:40:11
Scala Build Tool
Welkin 2017-01-31 14:40:14
ew
noan 2017-01-31 14:40:17
XD
noan 2017-01-31 14:40:34
Koterpillar, got it working, thanks
noan 2017-01-31 14:40:48
.... why is atom crashing with my haskell project open O.o
Welkin 2017-01-31 14:41:07
could be anything
Welkin 2017-01-31 14:41:17
but if you want a stable haskell editor, use emacs with haskell-mode
noan 2017-01-31 14:42:04
I've never been able to get into emacs. Maybe with evil mode I could try. I'll look around for a decent editor
Sonolin 2017-01-31 14:42:21
spacemacs + haskell-mode + evil = bliss
markasoftware 2017-01-31 14:42:22
vim <-- found one right here
Sonolin 2017-01-31 14:42:33
but yea vim works just as well (maybe not as shiny)
markasoftware 2017-01-31 14:42:36
noan: rearrange the letters of your name to find a decent editor
markasoftware 2017-01-31 14:42:44
;)
noan 2017-01-31 14:43:40
markasoftware, but nano sucks. also my name is a bad attempt at writing nån XD
markasoftware 2017-01-31 14:43:51
nano .vimrc
markasoftware 2017-01-31 14:44:45
are emacs keybindings as bad for your hand as the legend says
markasoftware 2017-01-31 14:44:48
?
Koterpillar 2017-01-31 14:45:04
vim with haskell-mode isn't bad either