Search Haskell Channel Logs

Thursday, February 2, 2017

#haskell channel featuring dolio, EvanR, dogweather, lpaste, reactormonk, lambdabot, and 11 others.

ertes 2017-02-02 11:45:11
evil! you can't reason about unix in terms of fixed points!
dolio 2017-02-02 11:45:23
People always forget that Haskell has all the finitary types that e.g. ML does (and ML has the infinitary ones). They're just written down slightly differently.
dolio 2017-02-02 11:45:46
And people tend not to use the finitary definitions.
EvanR 2017-02-02 11:46:07
your finitary list causes the whole thing to be evaluated early
EvanR 2017-02-02 11:46:21
as a "side effect"
dolio 2017-02-02 11:46:21
So does ML.
EvanR 2017-02-02 11:46:31
finite and lazy would be better
erisco 2017-02-02 11:46:33
how can I find what package a module comes from in ghci?
glguy 2017-02-02 11:46:54
erisco: From outside of ghci you can use: ghc-pkg find-module
erisco 2017-02-02 11:46:54
tracking down these sources has been a royal PITA -.-
erisco 2017-02-02 11:47:03
thanks
erisco 2017-02-02 11:47:50
how do I remember little commands like that
ertes 2017-02-02 11:48:07
dolio: i do use them, but i rarely think of them as "finitary!" or "data!", but rather as "faster!"
glguy 2017-02-02 11:48:31
erisco: I don't think that science fully understands memory yet
erisco 2017-02-02 11:49:24
still waiting for the cranial micro SD slot
EvanR 2017-02-02 11:49:31
why dont we remember the future
EvanR 2017-02-02 11:49:49
and what makes memory of the past legitimate
erisco 2017-02-02 11:50:07
because it hasn't happened yet EvanR, and that's all you need to worry your pretty little head about :P
erisco 2017-02-02 11:50:50
there isn't enough space here to unravel the timey wimey ball of this issue
Cale 2017-02-02 11:51:00
I can remember the future. Thanks, sandworms. Thandworms.
erisco 2017-02-02 11:53:19
the thyme must flow
dogweather 2017-02-02 11:54:56
Anyone use encodePretty' from aeson-pretty?
glguy 2017-02-02 11:55:21
Cale: Look around you; how many people do you suppose know that reference? :)
dogweather 2017-02-02 11:56:16
I can't get a working import for Config. Anyone have an example invocation of encodePretty'?
glguy 2017-02-02 11:56:27
(it's a funny set of videos if anyone hasn't seen them already)
erisco 2017-02-02 11:56:53
was I wrong? a coincidence if I was
erisco 2017-02-02 11:58:51
the interaction of documentation and TH is an unpleasant one
erisco 2017-02-02 11:59:16
it is like you've documented the assembly instead of the source
reactormonk 2017-02-02 12:06:42
How can I generate a lens for a record that I don't have control over?
erisco 2017-02-02 12:06:54
the problem is that SDecide Nat poops out of this https://github.com/konn/type-natural/blob/master/Data/Type/Natural/Definitions.hs
erisco 2017-02-02 12:07:05
not sure how to figure out what the actual instance is
erisco 2017-02-02 12:07:39
download the source and use some compile flag to generate TH only?
glguy 2017-02-02 12:07:57
reactormonk: The same way you'd do it for one you did have control over
reactormonk 2017-02-02 12:08:08
glguy, with Generics?
glguy 2017-02-02 12:08:22
No, we usually don't use Generics for generating lens
glguy 2017-02-02 12:08:26
lenses
reactormonk 2017-02-02 12:08:38
Why not?
glguy 2017-02-02 12:09:44
It's too tricky to get them to come out efficiently, and Generics are awkward to use when you're trying to do something like constructing one top-level definition for every field of a record
reactormonk 2017-02-02 12:10:00
oke
glguy 2017-02-02 12:10:14
I have examples of how to do it but it relies on extra flags to encourage GHC to optimize it correctly, and it's harder to explain how to use
glguy 2017-02-02 12:10:33
So it's more common to use Template Haskell or to write them out by hand
erisco 2017-02-02 12:10:36
anyone know what the instance likely is?
erisco 2017-02-02 12:11:00
I wager it isn't complicated but I haven't any experience with this stuff to guess myself
erisco 2017-02-02 12:12:03
ultimately I want a type like a :~: b but for comparisons, so it constructs as LT, EQ, or GT, rather than EQ or NEQ
erisco 2017-02-02 12:12:34
because I really need the proof of a ~ b in scope in the EQ case
erisco 2017-02-02 12:12:44
otherwise I'd just use SOrd
kmelva 2017-02-02 12:13:15
given finite list of integers, lets say `foo = [1, 2, 5, 10, 15]`, could you check that the list is monotonic using `fold`?
erisco 2017-02-02 12:13:39
so I want to look at how SDecide Nat was done so I know how to write my own
erisco 2017-02-02 12:14:37
kmelva, yup
kmelva 2017-02-02 12:15:03
erisco: dammit, I sill don't see how... are you sure you can? :D
kmelva 2017-02-02 12:15:09
erisco: if so, don't tell me how :)
erisco 2017-02-02 12:15:35
well I am frustrated with searching for code at the moment so sure, I'll write it
glguy 2017-02-02 12:15:47
kmelva: You want to do it with Data.Foldable.fold ?
kmelva 2017-02-02 12:16:20
glguy: yup
erisco 2017-02-02 12:17:29
well you can easily get all the other folds from that
erisco 2017-02-02 12:19:25
can we, say, map the integers to some Monoid whose mempty and mappend does what we want? I don't think so
glguy 2017-02-02 12:19:37
we can
erisco 2017-02-02 12:19:40
I don't know what mempty is
glguy 2017-02-02 12:21:53
as long as we're allowed to use foldMap or map, at least
erisco 2017-02-02 12:21:57
you're saying there is an easy f in foldMap f that solves this?
noan_ 2017-02-02 12:23:21
does one need to update their hoogle data as they add dependencies to a project? I can get more info from ghc-mod than hoogle right now
kmelva 2017-02-02 12:23:21
erisco: I give up... :(
erisco 2017-02-02 12:25:34
maybe I can think of a rather ugly Monoid we can define
lpaste 2017-02-02 12:25:38
glguy pasted "foldMap implementation of isMonotonic for kmelva" at http://lpaste.net/352013
erisco 2017-02-02 12:27:26
:i Option
kmelva 2017-02-02 12:27:35
glguy: thanks! looks much more complicated than I thought it would :/...
kmelva 2017-02-02 12:27:43
Option is new for me...
erisco 2017-02-02 12:27:47
what is Option
glguy 2017-02-02 12:27:55
It's Maybe, but with a nicer Monoid instance
glguy 2017-02-02 12:28:06
instance Semigroup a => Monoid (Option a)
erisco 2017-02-02 12:28:21
I see
glguy 2017-02-02 12:28:28
compare to: instance Monoid a => Monoid (Maybe a) -- Defined in 'GHC.Base'
glguy 2017-02-02 12:28:40
You don't have to use Option of course, it just makes it easier.
glguy 2017-02-02 12:28:58
(assuming you already know what it is)
kmelva 2017-02-02 12:29:12
it says in the docs "Ideally, this type would not exist at all and we would just fix the Monoid instance of Maybe"
kmelva 2017-02-02 12:29:17
what are they referring to?
erisco 2017-02-02 12:29:39
Monoid demands an identity, Semigroup does not, and the Maybe instance for Monoid does not use the identity
glguy 2017-02-02 12:29:41
Instead of requiring a Monoid a instance, it requires a Semigroup a instance as seen in what I pasted above
erisco 2017-02-02 12:29:48
so it is over-constrained
kmelva 2017-02-02 12:30:36
allrighty... I'll have something to read in the morning :)
kmelva 2017-02-02 12:30:40
thanks folks, 'night...
reactormonk 2017-02-02 12:30:42
glguy, got a TH sample off hand?
glguy 2017-02-02 12:30:56
reactormonk: sample of it doing what?
reactormonk 2017-02-02 12:31:08
lenses
glguy 2017-02-02 12:31:26
Yeah, there are samples in the lens documentation in the Control.Lens.TH module
recursion-ninja 2017-02-02 12:33:02
Hey guys I have a haskell frogram that segfaults when I call a C FII function. I ran valgrind on the Haskell executable and it looks like a null pointer is being passed as a parameter to the C function despise have non-null pointers being passed on the Haskell side. Do you guys have any ideas on how to debug this?
erisco 2017-02-02 12:33:27
glguy, that is an excellent answer. I've bookmarked it :)
reactormonk 2017-02-02 12:33:37
glguy, kk, thanks
glguy 2017-02-02 12:34:01
recursion-ninja: I'd check that you've imported the C function with the correct Haskell type.
systadmin 2017-02-02 12:34:58
> map odd [1, 3, 5]
lambdabot 2017-02-02 12:35:00
[True,True,True]
recursion-ninja 2017-02-02 12:35:28
glguy: I think I've generated the pointer to the C struct correctly, but hsc2hs seems like there's a lot of "black magic" occuring and I fear I've made a mistake somewhere with hsc2hs and the source of the error is obscured.
M0000 2017-02-02 12:35:34
I'm getting a seg fault… is it wrong to run an InterpreterT computation (enter it and exit it) twice in the same program?
erisco 2017-02-02 12:35:59
glguy, I was thinking similarly but was stuck with NotMonotonic not being an identity, but wrapping it in Option works
M0000 2017-02-02 12:36:10
also any advice for debugging a seg fault would be helpful
Tuplanolla 2017-02-02 12:36:25
Why is everyone getting segmentation faults today?
recursion-ninja 2017-02-02 12:36:25
M0000: Same boat as me, huh?
erisco 2017-02-02 12:36:44
glguy, then also I was thinking to store just a number rather than a range which should work but becomes dependent on the fold association
recursion-ninja 2017-02-02 12:36:50
Tuplanolla: Clearly, it's national segfault day in Haskellandia!
M0000 2017-02-02 12:36:51
recursion-ninJa: I wasn't following the conv, you have a seg fault?
erisco 2017-02-02 12:37:02
glguy, so I suppose that is either a feature or a defect
recursion-ninja 2017-02-02 12:37:13
M0000: Yeah, with hsc2hs and a C FFI binding.
dmwit 2017-02-02 12:37:36
> appEndo (foldMap (\x -> Endo (\(isMonotonic, min) -> (maybe isMonotonic (\m -> x <= m && isMonotonic) min, Just x))) [1,2,3,4]) (True, Nothing)
lambdabot 2017-02-02 12:37:38
(True,Just 1)
dmwit 2017-02-02 12:37:46
> appEndo (foldMap (\x -> Endo (\(isMonotonic, min) -> (maybe isMonotonic (\m -> x <= m && isMonotonic) min, Just x))) [1,2,4,3]) (True, Nothing)
lambdabot 2017-02-02 12:37:49
(False,Just 1)
erisco 2017-02-02 12:39:04
dmwit, oh the ranges are dependent on association too, of course
erisco 2017-02-02 12:39:07
why a range then
M0000 2017-02-02 12:39:31
recursion-ninja: if someone else comes here with a segfault then I think clearly Satan is at work
dmwit 2017-02-02 12:39:42
erisco: I'm not sure I understood your statement or your question.
erisco 2017-02-02 12:40:01
dmwit, that is because I am replying to the wrong person :P got confused
dmwit 2017-02-02 12:40:35
erisco: FWIW, my solution stores just a number and not a range. =)
glguy 2017-02-02 12:42:29
erisco: No, the ranges aren't impacted by reassociation