Search Haskell Channel Logs

Thursday, March 9, 2017

#haskell channel featuring sshine, Jenaf, ezyang, MarcelineVQ, stevenxl, teto, and 9 others.

Welkin 2017-03-09 13:46:10
inferno-cop: that has been taken to its logical extreme with classy-prelude
Welkin 2017-03-09 13:46:17
and it's a monster
Welkin 2017-03-09 13:46:29
too many typeclasses makes the code impossible to understand
glguy 2017-03-09 13:46:35
gaudy-prelude?
inferno-cop 2017-03-09 13:46:44
Oh, I hadn't heard about that, but I can definitely imagine it...
Welkin 2017-03-09 13:46:56
I think the name 'classy' refers to typeclasses :P
`Guest03 2017-03-09 13:47:03
inferno-cop: in that case, either that typeclass had to provide algorithm complexity restrictions or hadn't
`Guest03 2017-03-09 13:47:28
in first case, there are less !'s which could make it into the typeclass
`Guest03 2017-03-09 13:47:54
in the second case, you can write less code or be less sure about its complexity
`Guest03 2017-03-09 13:48:19
have to *
Welkin 2017-03-09 13:49:40
`Guest03: not having generic functions like `fmap` means you can never write generic functions yourself
inferno-cop 2017-03-09 13:49:41
Fair point.
Welkin 2017-03-09 13:49:50
that is horrible
Welkin 2017-03-09 13:49:53
you have a function you want to operate on Lists, and on Array, and on Map, and on etc.
Welkin 2017-03-09 13:50:41
have to copy/paste it several times
Welkin 2017-03-09 13:50:52
it's just stupid
`Guest03 2017-03-09 13:50:52
Welkin: i never said that we don't need generic functions
Welkin 2017-03-09 13:50:52
that is why Elm sucks
Welkin 2017-03-09 13:50:52
at least one reaosn
`Guest03 2017-03-09 13:50:52
i said that i need names for specialized versions too
`Guest03 2017-03-09 13:50:52
defined in modules.
Welkin 2017-03-09 13:50:52
`fmap :: (a -> b) -> [a] -> [b]` -- `Guest03 , done
inferno-cop 2017-03-09 13:50:52
But at the same time, lists, arrays, maps, sets etc are all different in important ways, so writing generic implementations of algorithms for them would seldom be a good idea (if you care about performance)
Welkin 2017-03-09 13:50:52
there is your specialized fmap for List
`Guest03 2017-03-09 13:50:52
Welkin: too verbose
`Guest03 2017-03-09 13:50:52
could just use L.map
Jenaf 2017-03-09 13:50:52
I still have the feeling that I'm producing ugly code:
Jenaf 2017-03-09 13:50:52
ieldReducer rows (a:(b:list))= (fmap (bfRowSetZeroPastN b) (Seq.take (b-a) rows))><(fieldReducer (Seq.drop (b-a) rows) (b:list))
Welkin 2017-03-09 13:50:57
Jenaf: this ain't lisp
Welkin 2017-03-09 13:50:58
!
Jenaf 2017-03-09 13:54:22
I'm quite sure I don't have the perfect representation of the Problem I want to tackle.
MarcelineVQ 2017-03-09 13:54:37
`Guest03: it's bad form for a bot to guess what you intend, it tends to produce noise
`Guest03 2017-03-09 13:54:57
that's bad if noise is very bad
MarcelineVQ 2017-03-09 13:55:06
noise is very bad
`Guest03 2017-03-09 13:55:19
it's not very bad for me...
Welkin 2017-03-09 13:55:21
Jenaf: something more like this http://lpaste.net/353366
Welkin 2017-03-09 13:55:27
but add type signatures to your functions
`Guest03 2017-03-09 13:55:35
okay
Jenaf 2017-03-09 13:56:04
I think i always have signatures
Jenaf 2017-03-09 13:56:13
thats what i start with when writin a function
Welkin 2017-03-09 13:56:35
Jenaf: I see you are using list comprehensions in your code as well
Welkin 2017-03-09 13:56:45
try to avoid those, especially for your use case
Welkin 2017-03-09 13:56:50
just use a simple `filter` instead
Jenaf 2017-03-09 13:57:00
can you tell me an example line?
Jenaf 2017-03-09 14:04:37
what I don't really like is stuff like
Jenaf 2017-03-09 14:04:38
if isNothing squares
Jenaf 2017-03-09 14:04:40
then Nothing
Jenaf 2017-03-09 14:04:41
else Just $ foo (fromMaybe (error "unreachable") squares)
Koterpillar 2017-03-09 14:04:59
Jenaf: this is fmap foo
inferno-cop 2017-03-09 14:05:00
that can be rewritten!
Welkin 2017-03-09 14:05:12
try to avoid using if-then-else
Welkin 2017-03-09 14:05:21
it is not idiomatic and there are almost always better ways to write it
Koterpillar 2017-03-09 14:05:22
> let foo = (* 2) in fmap foo (Just 3)
lambdabot 2017-03-09 14:05:27
Just 6
Koterpillar 2017-03-09 14:05:31
> let foo = (* 2) in fmap foo Nothing
lambdabot 2017-03-09 14:05:34
Nothing
Welkin 2017-03-09 14:05:34
use pattern matching as much as possible
Welkin 2017-03-09 14:05:41
and higher-order functions
Jenaf 2017-03-09 14:05:48
yeah
drostie 2017-03-09 14:05:59
What I like about $ is that a $ b $ c $ d is equal to a . b . c $ d.
Welkin 2017-03-09 14:06:22
and yes, the Myabe Monad instance
Koterpillar 2017-03-09 14:08:06
functor
stevenxl 2017-03-09 14:18:58
Hi folks. I'm reading Real World Haskell and I have to run ghc -c to compile a source file to object code.
stevenxl 2017-03-09 14:19:00
Those directions seem to be out of date
stevenxl 2017-03-09 14:19:00
What should I replace them with?
ezyang 2017-03-09 14:19:00
what's the full snippet? ghc -c still works
dunx 2017-03-09 14:19:02
stevenxl: man ghc
dunx 2017-03-09 14:19:13
iirc -c works tho
dunx 2017-03-09 14:19:23
did for me last time i was writing progs in haskell
mbw 2017-03-09 14:19:34
stevenxl: Generally, the comments you can find on the online version of the books are very helpful.
mbw 2017-03-09 14:19:41
*book
inferno-cop 2017-03-09 14:20:06
ghc -c works for me, just tested it
mbw 2017-03-09 14:20:17
Most of the issues which arise from RWH being dated are adressed there.
stevenxl 2017-03-09 14:20:33
mbw: online version you say?
Jenaf 2017-03-09 14:20:37
I'm going to bed
Jenaf 2017-03-09 14:20:45
see you later space cowboys
stevenxl 2017-03-09 14:20:52
inferno-cop: weird. I am using stack so running `stack ghc -c Source.hs`
mbw 2017-03-09 14:20:57
http://book.realworldhaskell.org/read/
inferno-cop 2017-03-09 14:21:19
stevenxl: Ah, stack. I didn't try that
stevenxl 2017-03-09 14:21:47
mbw: thank you!
stevenxl 2017-03-09 14:21:56
inferno-cop: do I have the wrong program installed?
stevenxl 2017-03-09 14:22:32
I see the -c option in `man ghc`. Stop after generating object file.
mbw 2017-03-09 14:22:33
What are you using the object files for? I don't remember this from reading the book.
stevenxl 2017-03-09 14:23:11
http://book.realworldhaskell.org/read/writing-a-library-working-with-json-data.html
stevenxl 2017-03-09 14:23:29
mbw: the module is not set up to correctly generate an executable. missing the main function, etc.
stevenxl 2017-03-09 14:23:37
i think i'm just going to brew install ghc and take it from there
mbw 2017-03-09 14:34:35
sshine: I think you need guard from Control.Monad.
sshine 2017-03-09 14:35:27
teto, did you find http://stackoverflow.com/questions/8748660/is-there-a-better-way-to-write-a-string-contains-x-method ?
sshine 2017-03-09 14:35:49
mbw, cool, thanks.
teto 2017-03-09 14:36:53
sshine: I had found others but this one looks better thanks !