Search Haskell Channel Logs

Sunday, January 29, 2017

#haskell channel featuring tdammers, Tuplanolla, athan, AWizzArd, Cale, mpickering, and 10 others.

ph88 2017-01-29 09:45:56
ertes, you want to see my source file, i don't think there is much room to factor out stuff but perhaps you see some patterns which i don't
ertes 2017-01-29 09:46:49
ph88: i'd rather not look at 4K LoC this evening =)
ph88 2017-01-29 09:46:55
ok :P
ertes 2017-01-29 09:47:44
the two techniques that really help reducing code size are abstraction (like foldr) and composition (i.e. come up with a minimal domain-specific language and express everything in that one)
ph88 2017-01-29 09:48:06
yeah i'm not quite there yet though
ph88 2017-01-29 09:48:14
atm i'm focusing on reducing compilation time
ertes 2017-01-29 09:48:41
less code = shorter compile times ;)
ph88 2017-01-29 09:48:49
ok ok
Tuplanolla 2017-01-29 09:55:44
"If you need the database to be fast, we recommend not putting too much data in it."
Jello_Raptor 2017-01-29 09:58:06
so I'm contemplating using classy-prelude for a project of my, but the haddock page is painful
EvanR 2017-01-29 09:58:11
optimally, make sure there is no data in there at all
ertes 2017-01-29 09:58:28
that's what i call reductio ad absurdum =)
Jello_Raptor 2017-01-29 09:58:31
is there a way to get a haddock page with the closure of all the exported elements and their haddocks?
EvanR 2017-01-29 09:59:07
empty database has other benefits, like being able to prove any property for everything in it
tdammers 2017-01-29 09:59:39
Jello_Raptor: my personal experience with classy prelude confirms your fears. It's good, but the documentation is painful.
Jello_Raptor 2017-01-29 10:01:21
tdammers: yeah :/ this is project with some others who are going to be haskell newbs, and I want to restrict them to something total, with all the common functions and much less worrying about imports, but forcing them to gid through N layers of redirection in hackage to find what's in the base library is no-go.
tdammers 2017-01-29 10:03:07
Jello_Raptor: if they're Haskell newbs, absolutely recommend against classy-prelude
tdammers 2017-01-29 10:03:15
it's definitely a power tool
tdammers 2017-01-29 10:03:58
you're probably better off making your own prelude, re-exporting just a bunch of uncontroversial modules
tdammers 2017-01-29 10:04:08
Data.List, Data.Char, Data.Maybe, Control.Monad, that kind of stuff
Jello_Raptor 2017-01-29 10:04:36
mmm
Jello_Raptor 2017-01-29 10:06:54
seems reasonable, though I'd still like to prevent them from having access to the non-total functions in prelude (barring undefined and error)
tdammers 2017-01-29 10:07:14
eh
tdammers 2017-01-29 10:07:24
I'd solve that with code reviews and education
tdammers 2017-01-29 10:07:40
but if you have to, you can of course have your custom prelude import Prelude hiding (head, ...)
Jello_Raptor 2017-01-29 10:09:21
part of it is that even I end up making mistakes with that sort of thing that bite me in production.
Cale 2017-01-29 10:09:38
Tuplanolla: But yeah, compilation is super-linear -- it's often possible to chop a large module up into smaller ones, and the sum of compile times for the small modules will be smaller than the compile time for the large one.
Jello_Raptor 2017-01-29 10:10:01
but even then, it would be very nice to have some way to generate the haddock that's the closure of all the relevant imported and exported stuff.
tdammers 2017-01-29 10:10:46
Jello_Raptor: for my own custom prelude, I resorted to dumping a ghci :browse into a file, and pasting that into the export list
athan 2017-01-29 10:21:15
What is a "zipper", not in ekmett terms? :) I've seen something similar to `([a], [a])` where the head of the first list is the "focus" (maybe)
EvanR 2017-01-29 10:21:37
theres that one and ([a], a, [a])
EvanR 2017-01-29 10:21:51
the second one is a comonad
athan 2017-01-29 10:22:06
ahh! Do you know where I can find more info about them?
EvanR 2017-01-29 10:23:06
thats the simplest zipper, you can get more elaborate
EvanR 2017-01-29 10:23:22
https://en.wikibooks.org/wiki/Haskell/Zippers
athan 2017-01-29 10:23:59
awesome, thanks EvanR
AWizzArd 2017-01-29 10:24:07
I want to call this from the shell via `cat file.txt | ./myProg` to list the contents of a file, prefixed by the line number. Works: main = interact $ unlines . map (\(i, s) -> show i ++ ". " ++ s) . zip [1..] . lines I wonder now if using zip [1..] is the best way to create an indexed sequence for map.
byorgey 2017-01-29 10:27:27
AWizzArd: zip [1..] is fairly idiomatic.
byorgey 2017-01-29 10:28:06
AWizzArd: if you want to get really crazy you could use an indexed traversal from the 'lens' library, but honestly a simple zip [1..] is best.
AWizzArd 2017-01-29 10:28:30
Okay thanks.
Gurkenglas 2017-01-29 10:29:10
AWizzArd, map (\(x, y) -> f x y) $ zip a b is zipWith f a b
AWizzArd 2017-01-29 10:29:34
byorgey: one more question: if I don't want to read from standard input, but forward the results of a `readFile` into my expression above, is there a way to do this?
mpickering 2017-01-29 10:29:53
How do I tell stack to use the version of GHC on my command line?
Gurkenglas 2017-01-29 10:30:25
main = putStrLn . unlines . zipWith (\i s -> show i ++ ". " ++ s) . lines =<< readFile "file.txt" -- AWizzArd
AWizzArd 2017-01-29 10:30:43
Gurkenglas: ah yes, I haven't seen this =<< yet. Good, danke!
mpickering 2017-01-29 10:32:37
I don't understand why when it looks for ghc-8.0.1 it refuses to use the binary called ghc-8.0.1 which is on my path
lpaste 2017-01-29 10:39:13
jadlr pasted "type class instance for servant" at http://lpaste.net/351774
ph88_ 2017-01-29 10:40:13
geekosaur, you told me about enum, can i use that to replace pattern matching as well ? https://paste.fedoraproject.org/540395/57259731/ so that here i can do something with P.pretty and [SSimpleName .. SALL] ??
jadlr 2017-01-29 10:40:14
Hi, I'm trying to create a type class instance for servant and I am stuck. How can I create the type class above without getting the orphan warning?
jadlr 2017-01-29 10:41:02
This is the code: http://lpaste.net/351774
geekosaur 2017-01-29 10:41:04
ph88_, sadly no
geekosaur 2017-01-29 10:43:37
ph88_, tht's one of the places where things tend to get ugly and require boilerplate
ph88_ 2017-01-29 10:44:29
boilerplate like template haskell ?