Search Haskell Channel Logs

Friday, February 10, 2017

#haskell channel featuring tsahyt, cocreature, monochrom, jchia, lambdabot, geekosaur, and 5 others.

jchia 2017-02-09 20:51:27
cabal/stack question: What's the different between --enable-executable-profiling & --enable-library-profiling? What do 'executable' & 'library' refer to? Do they mean code for executables & code for modules respectively?
ezyang 2017-02-09 20:56:44
jchia: It's terrible and you shouldn't pay much attention to it
ezyang 2017-02-09 20:57:05
but basically, it just controls whether or not the library is built with profiling, and whether or not the executable is built with profiling
jchia 2017-02-09 20:58:00
ezyang: Can I say I want profiling for my project libraries & executables but not for packages that my project uses?
ezyang 2017-02-09 20:58:30
That's a different issue
ezyang 2017-02-09 20:58:53
you must compile every library transitively depended upon with profiling
ezyang 2017-02-09 20:59:04
but you're probably asking about what cost centers get stats reported
jchia 2017-02-09 20:59:06
ezyang: I suppose what I'm looking for doesn't exist, then
jchia 2017-02-09 20:59:37
For debugging, I just want to see my own functions in a stack trace when I get an error.
ezyang 2017-02-09 20:59:49
look at http://cabal.readthedocs.io/en/latest/nix-local-build.html#cfg-field-profiling-detail
ezyang 2017-02-09 21:01:09
you probably want toplevel-functions
qmm 2017-02-09 21:01:13
is there an equivalent of repeat for Vector?
geekosaur 2017-02-09 21:01:41
the problem with not profiling the libraries you use is that laziness means your thunks may be forced in those libraries (which won't then profile them properly) and their thunks may be forced in your code (which then might also mis-profile)
geekosaur 2017-02-09 21:02:12
basically you end up with profiling output that is at best untrustworthy and at worst completely meaningless
geekosaur 2017-02-09 21:02:41
so ghc tries to prevent you from doing it
dhalgren_ 2017-02-09 21:02:42
is these something pointfree I could do instead of \(x,y)->(x, y x) ?
geekosaur 2017-02-09 21:03:17
@src (,) fmap
lambdabot 2017-02-09 21:03:17
fmap f (x,y) = (x, f y)
geekosaur 2017-02-09 21:03:32
so, not exactly
dhalgren_ 2017-02-09 21:03:38
hm!
jchia 2017-02-09 21:04:04
((,,) <$> fst <*> snd <*> fst)
ezyang 2017-02-09 21:04:07
geekosaur: The need to profile libs is more of a technical limitation
jchia 2017-02-09 21:04:37
sorry, misread
jchia 2017-02-09 21:07:17
dhalgren_: pointfree.io has something but it's ugly
dhalgren_ 2017-02-09 21:08:00
haha, thx, I'll take a look
geekosaur 2017-02-09 21:08:02
@pl \(x,y)->(x, y x)
lambdabot 2017-02-09 21:08:02
uncurry (liftM2 (.) (,) (flip id))
geekosaur 2017-02-09 21:08:15
but you dont get non-ugly for that I'm pretty sure
dhalgren_ 2017-02-09 21:08:16
yeah
dhalgren_ 2017-02-09 21:09:29
so that's a pointfreefy bot? nice :D
tsahyt 2017-02-09 21:09:44
qmm: vectors are finite, there can't be an equivalent of repeat. There is replicate though.
geekosaur 2017-02-09 21:09:46
also known as the obfuscated code generator >.>
qmm 2017-02-09 21:10:06
tsahyt: ruh roh!
dhalgren_ 2017-02-09 21:10:24
@pl \(x,y) -> (x, zipWith (+) x y)
lambdabot 2017-02-09 21:10:24
uncurry (liftM2 (.) (,) (zipWith (+)))
qmm 2017-02-09 21:10:25
monochrom: your emerge function will not work
tsahyt 2017-02-09 21:10:28
qmm: what would you need that for?
dhalgren_ 2017-02-09 21:10:31
yeah, uf
qmm 2017-02-09 21:10:56
emerge xs ys = V.zipWith (++) (map (:[]) xs ++ repeat ([""])) ys
qmm 2017-02-09 21:11:12
merge xs ys = zipWith (++) (map (:[]) xs ++ repeat ([""])) ys -- rather
monochrom 2017-02-09 21:11:55
Maybe "" needs to be BL.empty because you're doing ByteString.
geekosaur 2017-02-09 21:11:57
@djinn (a, b -> c) -> (a, c)
lambdabot 2017-02-09 21:11:57
-- f cannot be realized.
qmm 2017-02-09 21:12:00
merge xs ys = V.zipWith (V.++) (V.map (V.cons []{- <-um.. -}) xs V.++
geekosaur 2017-02-09 21:12:09
figured. exference didn't like it either
monochrom 2017-02-09 21:12:21
(:[]) becomes V.singleton
geekosaur 2017-02-09 21:12:40
actually I think I got that type wrong, it makes no sense
monochrom 2017-02-09 21:13:01
you will have to replace "repeat" by "V.replicate something something" and compute the necessary length yourself
geekosaur 2017-02-09 21:13:19
@djinn (a, a -> c) -> (a, c)
lambdabot 2017-02-09 21:13:19
f (a, b) = (a, b a)
monochrom 2017-02-09 21:13:31
There is also the issue of urls :: [String] but you will need [ByteString] eventually
dhalgren_ 2017-02-09 21:13:31
well, yes
geekosaur 2017-02-09 21:13:35
yeh, nothing useful there, it doesnt generate pointfree
geekosaur 2017-02-09 21:13:47
and "piping" it through @pl would just get you the same garbage
geekosaur 2017-02-09 21:14:04
@. pl djinn (a, a -> c) -> (a, c)
lambdabot 2017-02-09 21:14:04
f = uncurry (liftM2 (.) (,) (flip id))
qmm 2017-02-09 21:14:31
monochrom: there isn't an equivalent of repeat for Vector i'm told
qmm 2017-02-09 21:14:41
merge xs ys = zipWith (++) (map (:[]) xs ++ repeat ([""])) ys
monochrom 2017-02-09 21:14:52
you will have to replace "repeat" by "V.replicate something something" and compute the necessary length yourself
Lokathor 2017-02-09 21:14:59
vector is sadly light on the functions it includes
geekosaur 2017-02-09 21:15:07
repeat makes no sense for a vector
geekosaur 2017-02-09 21:15:11
vectors are fixed length
geekosaur 2017-02-09 21:15:14
as has already been stated
qmm 2017-02-09 21:15:19
merge xs ys = V.zipWith (V.++) (V.map (V.singleton) xs V.++ V.repeat ([BL.empty])) ys
geekosaur 2017-02-09 21:15:23
wishing will not change that
monochrom 2017-02-09 21:15:32
No, vector is sadly heavy and plentiful on the functions it includes.
tsahyt 2017-02-09 21:15:48
monochrom: why sadly?
dhalgren_ 2017-02-09 21:15:49
its prob as good as its gonna get . I was thinking (\(x,y)-> (x, y x)).(id *** (zipWith (+))) and then something for that pointed part to clean it up but prob then what I started with is better \(x,y) -> (x, zipWith (+) x y)
monochrom 2017-02-09 21:16:25
When I look at its doc, it goes on forever and longer than Data.List and makes me think "I thought list was the infinitely long one"
Lokathor 2017-02-09 21:17:22
monochrom, sorry, I mean that DAta.Vector.Unboxed.Mutable specifically is light on the functions I often want :P
tsahyt 2017-02-09 21:17:23
and I still find myself missing some things from Data.Vector. There is unsafeHead and head but no safeHead for example
tsahyt 2017-02-09 21:17:42
i.e. Vector a -> Maybe a
monochrom 2017-02-09 21:18:39
OK, yes, the mutable ones are impoverished. I think because "you can loop over read/write yourself, or you can always freeze-thaw"
monochrom 2017-02-09 21:19:32
But also yes they should have a view :: Vector a -> Maybe (a, Vector a)
dhalgren_ 2017-02-09 21:19:52
do people avoid partial functions systematically? even when the err state would actually be an impossible state (that should error out)?
Lokathor 2017-02-09 21:19:59
i don't follow why view gives back a vector
monochrom 2017-02-09 21:20:15
it merges head and tail
Lokathor 2017-02-09 21:20:23
ah ha
monochrom 2017-02-09 21:20:27
some people avoid partial functions religiously. I don't.
dhalgren_ 2017-02-09 21:21:03
seems to me a shame to deal w some Maybe wrapper when in the end I really want to Nothing -> error "wtf?" anyhow
Lokathor 2017-02-09 21:21:14
dhalgren_, if there's an error state you can reach only when things are unrecoverably bad to the "you'll need to rewrite and recompile this" point, then sure throw the error
tsahyt 2017-02-09 21:21:15
me neither, as long as I can guarantee that they're total under the assumption that my invariants hold
Lokathor 2017-02-09 21:21:19
:t fromJust
lambdabot 2017-02-09 21:21:20
Maybe a -> a
Lokathor 2017-02-09 21:21:24
dhalgren_, ^
tsahyt 2017-02-09 21:21:31
if they break in that case, there's no sane way to recover anyhow
monochrom 2017-02-09 21:21:31
I want view, not because of the totality religion, but because of the pattern-matching religion. http://www.vex.net/~trebla/haskell/crossroad.xhtml
dhalgren_ 2017-02-09 21:21:59
Lokathor: yeah, that fn is exactly my "sin" in some code I'm playing with
monochrom 2017-02-09 21:22:23
@quote monochrom safeFromJust
lambdabot 2017-02-09 21:22:23
monochrom says: I use safeFromJust :: Maybe a -> Maybe a
Lokathor 2017-02-09 21:22:30
hahahahah
monochrom 2017-02-09 21:22:42
And for a naughty one:
monochrom 2017-02-09 21:22:48
@quote monochrom unsafeCoerce
lambdabot 2017-02-09 21:22:48
monochrom says: isTrue = (unsafeCoerce :: Either a b -> Bool) . (unsafeCoerce :: Maybe c -> Either a b) . (unsafeCoerce :: Bool -> Maybe c)
Lokathor 2017-02-09 21:23:20
i can't even follow that one in IRC
monochrom 2017-02-09 21:23:36
Don't worry, I didn't test it.
cocreature 2017-02-09 21:23:40
Lokathor: it's just id, created by composing unsafeCoerce three times
Lokathor 2017-02-09 21:23:42
my window wraps it at just the wrong part to read it easily :P
tsahyt 2017-02-09 21:23:44
I want to test that though
Lokathor 2017-02-09 21:24:50
https://github.com/Lokathor/galaxy-break/blob/master/lib/GalaxyBreak.hs guys check out my sweet text adventure game
tsahyt 2017-02-09 21:24:53
TIL unsafeCoerce False :: Maybe c == Nothing
Lokathor 2017-02-09 21:24:55
there's FIVE whole rooms!
geekosaur 2017-02-09 21:25:53
tsahyt, yep. constructor tags start at 0, Bool has two of them as do Maybe and Either, Bool does not have associated values -> as long as you immediately unsafeCoerce away again instead of doing something that would access a value, it works
Lokathor 2017-02-09 21:26:26
sounds like rust's "nullable pointer optimization" with Option<&T>
dhalgren_ 2017-02-09 21:26:26
Lokathor: r u familiar with the interactive fiction scene? Inform seems like a fascinating language...
Lokathor 2017-02-09 21:26:48
dhalgren_, I know it exists, but because of the eventual scope of this game it's not at all suitable to my needs
dhalgren_ 2017-02-09 21:27:08
as in tiny or huge?
tsahyt 2017-02-09 21:27:23
geekosaur: I see. that's still terrible though.
Lokathor 2017-02-09 21:27:25
as in, this is a text adventure that morphs into an incrimental game :P
geekosaur 2017-02-09 21:27:27
it's moderately evil and requires knowing how ghc lays things out
dhalgren_ 2017-02-09 21:27:35
ha!
tsahyt 2017-02-09 21:27:38
I tried unsafeCoerce True :: Maybe c first and it broke ghci
Lokathor 2017-02-09 21:27:54
dhalgren_, https://github.com/Lokathor/galaxy-break/wiki explains it a bit
geekosaur 2017-02-09 21:27:55
and I think it is possible if you used it in some circumstances with ghc8 and optimization, it would break
geekosaur 2017-02-09 21:28:09
because ghc8 does some optimizations automatically that used to require annotations
tsahyt 2017-02-09 21:28:41
but doesn't that whole chain just optimize away to id anyhow? at the end it's just unsafeCoercing from Bool back to Bool
geekosaur 2017-02-09 21:29:01
(with respect to packing and unboxing... although ... it should not apply those to any type that has more than one constructor, so probably safe anyway)
geekosaur 2017-02-09 21:31:25
you'd hope. but unsafeCoerce is actually somewhat tricky and even if you think you know what you are doing you can get into trouble
geekosaur 2017-02-09 21:32:52
btw I *think* you could have done that in separate steps in ghci if you disabled the automatic `print it`
geekosaur 2017-02-09 21:33:05
but, as I said, it's a bit tricky
dhalgren_ 2017-02-09 21:34:31
Lokathor: I'd suggest you take a look at some intfiction regardless (and maybe some articles - famous author Emily Short has a rather rich blog for eg, w bunch of theory etc), simply to evaluate their take (takes actually) on the UI; for eg in my experience, there's nothing more frustrating than an overly primitive parser that promises more freedom than it delivers. yet there are ways to make its
dhalgren_ 2017-02-09 21:34:37
affordances clearer even if smallish (modern restricted parser games)
tsahyt 2017-02-09 21:36:11
geekosaur: I've never had a real world usecase for it anyhow tbh
bollu 2017-02-09 21:36:45
STGI uses trifecta, right?
geekosaur 2017-02-09 21:38:19
tsahyt, afaik the only real world usecase for it is manually optimizing an edge case in newtype wrappers
tsahyt 2017-02-09 21:38:40
what edge case would this be?
tsahyt 2017-02-09 21:38:48
I thought the wrapper optimizes away completely anyhow?
geekosaur 2017-02-09 21:39:26
it's supposed to but there is some case I am not recalling where the compiler can't completely optimize it away and you end up with a pointless runtime call to id
tsahyt 2017-02-09 21:40:06
that sounds like it'd be very hard to find in the first place
Lokathor 2017-02-09 21:40:10
dhalgren_, I'd say that my plans, in terms of interface, are more influenced by Aardwolf MUD than anything else, if you're familiar with it, or with MUDs in general
geekosaur 2017-02-09 21:41:56
tsahyt, as I understand it, is's actually a fairly formulaic situation (and the fact that the compiler can't optimize it is an ongoing frustration, but it's a particularly tricky case to deal with from the compiler, it's only "obvious" to people)
dhalgren_ 2017-02-09 21:42:34
aha, I see. well, I played only a handfull of sessions on one server, can't even identify which off the top of my head, though it was FUDGE based and scifiish..
tsahyt 2017-02-09 21:42:39
is there some resource that I can read about this? I think it'd be good to know what that case looks like just so I can avoid it
tsahyt 2017-02-09 21:42:53
especially because I've started to make very liberal use of newtype wrapping over the last year or so
qmm 2017-02-09 21:43:01
monochrom: thank you for helping me today
bollu 2017-02-09 21:43:29
is there a tutorial for trifectra?
qmm 2017-02-09 21:44:01
monochrom: this isn't a rushed thing, i'll think on how to use V.replicate and compute the length
qmm 2017-02-09 21:44:20
anything i do in haskell is never rushed :P
geekosaur 2017-02-09 21:44:54
tsahyt, http://stackoverflow.com/questions/22847740/use-of-unsafecoerce at "A more common example"
monochrom 2017-02-09 21:45:07
You'r welcome