saurabhnanda 2017-01-26 19:46:13
just broadcasting this here -- https://www.reddit.com/r/haskell/comments/5qfd36/instrumentation_without_required_application/
dmj` 2017-01-26 19:48:26
glguy: hmm, would be nice if there was something like modify_ m f = modifyMVar_ m $ \x -> pure (f x)
glguy 2017-01-26 19:48:59
modifyMVar_ m (pure . f) for now I guess
glguy 2017-01-26 19:50:26
How about? modifyMVar_ m (\x -> do let {x' = f x}; forkIO (evaluate x'); return x')
glguy 2017-01-26 19:50:38
so you can let go of the mvar quickly and force it in another thread :)
dmj` 2017-01-26 19:55:49
ah :) that's nice
glguy 2017-01-26 19:58:01
or perhaps par and that family would be better for that
tippenein 2017-01-26 20:13:50
I'm looking for something like guard (isJust maybeSomething) >>= \something -> ...
glguy 2017-01-26 20:15:46
maybe mzero <...> maybeSomething
glguy 2017-01-26 20:15:48
behaving like that?
tippenein 2017-01-26 20:18:26
yeah, sorta like that. I'm sure I can finagle the function to be last arg
glguy 2017-01-26 20:19:12
if you didn't want the mzero behavior there's for_
mrkgnao 2017-01-26 20:20:36
this seems like a bad idea, and probably breaks the type system's guarantees and such, but is there a sane way to write a function that unwraps a type constructor?
glguy 2017-01-26 20:20:59
mrkgnao: what does that mean to you?
mrkgnao 2017-01-26 20:21:07
something such that forall SomeType. f (SomeType k) == k
mrkgnao 2017-01-26 20:21:11
in pseudo-Haskell
mrkgnao 2017-01-26 20:21:32
pretty sure that's impossible for some stupid reason I'm overlooking
glguy 2017-01-26 20:21:59
no, just because a type has a k parameter it doesn't mean there are any k typed values to get
mrkgnao 2017-01-26 20:21:59
I'd guess at a type like unwrapper :: (forall x. x -> f x) -> f a -> a
mrkgnao 2017-01-26 20:22:29
what about for a simple non-sum type?
mrkgnao 2017-01-26 20:22:37
like data T a = T a
glguy 2017-01-26 20:22:57
you could do it using the Data instance
glguy 2017-01-26 20:23:07
or using the Generics instance
glguy 2017-01-26 20:23:23
but not parametrically in all types
mrkgnao 2017-01-26 20:23:34
could you make an unwrapper for such types? in general, can you write functions that work according to the "shapes" of the datatypes? (which would probably be analogous to kinds, but for the types, not the constructors)
glguy 2017-01-26 20:23:39
and you'd get a Maybe k
glguy 2017-01-26 20:24:23
syb and ghc.generics are your search terms
mrkgnao 2017-01-26 20:24:25
so this is where the evil type-level programming begins.
mrkgnao 2017-01-26 20:24:47
haha, I'm not really looking to do this, I was just curious. thanks though! :)
mrkgnao 2017-01-26 20:27:04
glguy: what would an application of such things be?
mrkgnao 2017-01-26 20:27:36
I've noticed intero installs this syb package, but that's as far as I've come to encountering any of these in my short time with the language so far.
glguy 2017-01-26 20:31:26
maybe you have a big AST and you want to query what are all the Name typed values in an Expression