lyxia 2017-02-21 04:46:54
max3: what did you do that doesn't work
max3 2017-02-21 04:47:02
i got it working
max3 2017-02-21 04:47:05
thanks
merijn 2017-02-21 04:51:33
No, the name isn't what you use, you just do "myVar = declareIORefSource "foo" 1" and then use myVar to access it
max3 2017-02-21 04:52:16
yes that's what i meant
max3 2017-02-21 04:52:21
myVar
max3 2017-02-21 04:52:25
is in the global name space
max3 2017-02-21 04:52:33
through readIORef?
lyxia 2017-02-21 04:53:46
"foo" is in the global name space, and you bind the variable to myVar to use in regular Haskell code.
merijn 2017-02-21 04:54:50
lyxia: Well, myVar is global too if you just export it or whatever
lyxia 2017-02-21 04:56:08
oh right
max3 2017-02-21 04:56:38
how do i bind "foo" to another variable after it's been declared?
Rembane 2017-02-21 04:56:52
max3: let bar = foo in ...
max3 2017-02-21 04:59:24
http://pastebin.com/ftHB1mFQ
max3 2017-02-21 04:59:28
what am i doing wrong?
Rembane 2017-02-21 05:01:49
max3: Try let b = someVar1 instead.
merijn 2017-02-21 05:01:50
max3: You should use "someVar1"
max3 2017-02-21 05:01:50
Rembane let b = someVar1 will work
max3 2017-02-21 05:01:50
merijn, don't understand
max3 2017-02-21 05:02:01
the question is how to access the global through the quoted identifier
merijn 2017-02-21 05:03:07
Why do you want that?
max3 2017-02-21 05:03:28
well 1 i'm just curious 2 i'm interested in accessing this global in other modules
max3 2017-02-21 05:03:38
merijn, as you said i could export
merijn 2017-02-21 05:03:39
max3: Then you just export someVar1?
max3 2017-02-21 05:04:04
yes i was wondering if there were another way
nate__ 2017-02-21 05:07:39
Is there anyone here who understands Core well?
merijn 2017-02-21 05:08:10
ish? :p
Rembane 2017-02-21 05:08:34
nate__: Ask and we'll see if anyone answers. :)
nate__ 2017-02-21 05:09:33
I've been trying to read through the -ds and -spec output, and see a lot of symbols like $dApplicative and $fAlternativeRedexT_$c<|>
nate__ 2017-02-21 05:09:54
What is the meaning of the dollar sign in these symbols?
nate__ 2017-02-21 05:10:39
Other symbols like void# --- what does the pound sign mean?
erisco 2017-02-21 05:10:57
that is magic hash which is a special GHC feature that does unboxing of values
merijn 2017-02-21 05:11:00
# is usually unboxed types
nate__ 2017-02-21 05:11:47
In some places, I see lines like (\ @ b -> ...)
erisco 2017-02-21 05:12:16
> (\@b -> 3) 5
kgadek 2017-02-21 05:12:18
nate__: http://stackoverflow.com/a/1153485/547223
lambdabot 2017-02-21 05:12:20
nate__ 2017-02-21 05:12:22
I looked in the pretty printer code, and it said the @ symbol meant lambda-bound variables, but it wasn't clear to me why that was a distinction.
erisco 2017-02-21 05:12:32
I don't think it is valid syntax
erisco 2017-02-21 05:13:06
x@y is valid and binds y to x
erisco 2017-02-21 05:13:17
so, a common use is xxs@(x:xs)
erisco 2017-02-21 05:13:27
that way you get the head, the tail, plus the cons of the two
nate__ 2017-02-21 05:13:42
It doesn't appear that that's the meaning of '@' in this context.
tabaqui1 2017-02-21 05:13:52
I've read somewhere that quotRem is much faster than divMod
tabaqui1 2017-02-21 05:14:09
or maybe vice versa
tabaqui1 2017-02-21 05:14:12
dunno
tabaqui1 2017-02-21 05:14:13
is it true?
erisco 2017-02-21 05:14:21
well, if you could show where that exists I'd like to know
kgadek 2017-02-21 05:14:24
nate__: hmm was this in the core/STG output?
kgadek 2017-02-21 05:14:37
I don't recall the syntax for lambdas in STG
erisco 2017-02-21 05:14:59
there is \ ~b -> and \ !b -> so maybe you were thinking of one of those
nate__ 2017-02-21 05:15:07
kgadek: yes. See line 352 here https://ghc.haskell.org/trac/ghc/browser/ghc/compiler/coreSyn/PprCore.hs
Zemyla 2017-02-21 05:15:08
tabaqui1: quotRem is an Integer primitive, and divMod is defined by fiddling with the signs of those numbers, so it may be faster for Integers.
tabaqui1 2017-02-21 05:16:01
Zemyla: so quotRem is faster, right?
erisco 2017-02-21 05:16:02
> (\ @ b -> 3) 5
lambdabot 2017-02-21 05:16:05
kgadek 2017-02-21 05:16:17
no, there is `stuff \u stuff` but no at sign
erisco 2017-02-21 05:16:31
the spacing matters actually, but still this isn't valid syntax without some extension (which I have not heard of)
nate__ 2017-02-21 05:16:52
Not sure. I'm pulling this directly from a .dump-spec file
kgadek 2017-02-21 05:16:54
erisco: it appears that we're talking about Core, not actually Haskell
erisco 2017-02-21 05:17:06
oh, heh, well have fun :P
ph88 2017-02-21 05:17:35
i was looking at this tutorial https://generics-eot.readthedocs.io/en/latest/tutorial.html#th-example-meta-information-with-types-generating-sql-schemas and wondering if this does allow me to find a field of a certain type in a data structure, can i test for a specific type and then change the value? does someone know?
nate__ 2017-02-21 05:18:12
A complete example: $s=<< = \ @ a @ b f x -> >>= $fMonadMaybe x f
kgadek 2017-02-21 05:18:17
nate__: I have a blurry memory so I may be wrong, but… this may be true. So this `@stuff` would be a dictionary containing instance methods
Zemyla 2017-02-21 05:19:27
tabaqui1: Probably. Try benchmarking it to be sure, though.
kgadek 2017-02-21 05:19:38
that's how you deal with ad-hoc polymorphism anyway: passing a dictionary that contains actual methods
kgadek 2017-02-21 05:19:54
the same is with C++, but it's called vptr there
kgadek 2017-02-21 05:19:58
(or sth like that)
lyxia 2017-02-21 05:19:58
ph88: you can by adding a typeable constraint to the field
nate__ 2017-02-21 05:20:58
You're thinking of the virtual function table
ph88 2017-02-21 05:21:15
lyxia, yeah ok i thought i first try without Data and Typeable
nate__ 2017-02-21 05:21:18
Rather, the pointer thereto.
lyxia 2017-02-21 05:22:26
ph88: You could also use some overlapping instances
nate__ 2017-02-21 05:22:55
kgadek: The weird thing is that the names preceded by the '@' seem to never be used.
ph88 2017-02-21 05:23:05
lyxia, how do you figure overlapping instances help ?
lyxia 2017-02-21 05:23:35
ph88: because you can write one instance for all types, and one instance for all types that match
kgadek 2017-02-21 05:23:40
nate__: hmm. Do you have optimization passes turned on?
nate__ 2017-02-21 05:24:06
Other than dumping the output, I have no special flags.
lyxia 2017-02-21 05:24:21
ph88: and then the first instance will never be used for types that match, so you can assume that they don't.
ph88 2017-02-21 05:25:04
lyxia, if you look at the EotCreateTableStatement function .. i think it's possible to get the type with show (typeRep (Proxy :: Proxy x)) only that i don't need to show it i just need to compare it with a specific type to see if it's the one i need
ph88 2017-02-21 05:25:29
lyxia, the first as being the first in the source file ?
lyxia 2017-02-21 05:25:44
ph88: I thought you didn't want to use typeable
lyxia 2017-02-21 05:26:31
ph88: and I just showed how you can do it without it
kgadek 2017-02-21 05:26:35
nate__: so that's probably this. Or that's my guess
ph88 2017-02-21 05:26:38
lyxia, damn you got me, i didn't look carefully .. i thought GHC.Generics was providing this -___- ..
ph88 2017-02-21 05:27:00
isn't it possible to extract the type from the metadata ?
nate__ 2017-02-21 05:27:11
kgadek: any idea about the dollar sign in $dMonad or $fMonadMaybe?
nate__ 2017-02-21 05:27:57
It seems to exclusively appear by names of type classes
ph88 2017-02-21 05:28:04
lyxia, yes i will seriously consider that option if it can't be done with pure GHC.Generics
kgadek 2017-02-21 05:28:09
nate__: I have no in-depth practical knowledge on Core/STG. Sorry, can't help
nate__ 2017-02-21 05:28:45
Ah, okay. Well, thank you anyhow.
kgadek 2017-02-21 05:29:28
nate__: if you mind my guessing, then probably this fMonadMaybe is the dictionary for `Maybe`
kgadek 2017-02-21 05:29:52
but that's a wild shot
benneh 2017-02-21 05:30:43
With 'Writer w', the function 'tell' uses 'mappend :: w -> w -> w'. With 'WriterT w m', is there a monadic version of this which uses a function 'w -> w -> m w'?
nate__ 2017-02-21 05:30:46
Yeah, I'm starting to lean in about that direction. I wish I could find it documented though.
lyxia 2017-02-21 05:31:13
ph88: AFAIK the metadata only contains information about the type constructor and the constructors
codedmart 2017-02-21 05:31:19
If I have my own monad stack is it possible to forkIO within the stack?
nitrix 2017-02-21 05:31:45
codedmart: As long as your stack type has an instance of MonadIO, yes.
nitrix 2017-02-21 05:31:52
codedmart: You'll be able to liftIO . forkIO
ph88 2017-02-21 05:32:11
lyxia, aaaah ok then the way i had imagined is impossible. I will either have to use overlapping instances or use typeable
nitrix 2017-02-21 05:32:23
codedmart: Note that monad transformers over the IO monad automagically have a MonadIO instance.
codedmart 2017-02-21 05:32:24
nitrix: Hmm... It does and I thought I tried that. Let me try again.
nitrix 2017-02-21 05:32:59
(At least if you're using the existings transformers, not creating a new one)
lyxia 2017-02-21 05:35:43
benneh: it doesn't seem to easily obey the monad laws
ph88 2017-02-21 05:36:03
lyxia, this makes me think i'm better of going back to uniplate rather than whipping something up myself
lyxia 2017-02-21 05:36:42
ph88: why
ph88 2017-02-21 05:37:00
cuz i don't really know what i'm doing and i have experience with uniplate from last time
lyxia 2017-02-21 05:37:37
:/ Uniplate doesn't seem so good to me.
ph88 2017-02-21 05:37:43
oh :/
ph88 2017-02-21 05:37:48
can type by compared with Typeable ? if i have a function like a -> b -> Bool
SudhanshuJ 2017-02-21 05:37:54
How do I go about making a 2 player tic tac toe game in haskell ? I want to display the 3*3 grid as cordinates which each player would enter to make his move.
ph88 2017-02-21 05:37:55
by -> be
lyxia 2017-02-21 05:38:24
ph88: (Typeable a, Typeable b) => proxy a -> proxy b -> Bool
ph88 2017-02-21 05:38:31
SudhanshuJ, start with making some types to represent your data, then show us your code
lyxia 2017-02-21 05:38:47
ph88: comparing types is what Typeable is about
ph88 2017-02-21 05:38:53
lyxia, not to nitpick but don't you mean Proxy with capital P ?
codedmart 2017-02-21 05:39:03
nitrix: But the func that I call with forkIO needs to be IO correct?
ph88 2017-02-21 05:39:15
(Typeable a, Typeable b) => Proxy a -> Proxy b -> Bool
nitrix 2017-02-21 05:39:24
codedmart: Yeah.
nitrix 2017-02-21 05:39:27
:t forkIO
lyxia 2017-02-21 05:39:29
ph88: nope. They are actually isomorphic.
lambdabot 2017-02-21 05:39:29
error: Variable not in scope: forkIO
erisco 2017-02-21 05:39:41
probably not, seeing as the Proxy term is irrelevant ph88
nitrix 2017-02-21 05:39:41
codedmart: forkIO :: IO () -> IO ThreadId
lyxia 2017-02-21 05:39:43
ph88: but using a type variable makes it more polymorphic
codedmart 2017-02-21 05:39:45
That is what I am getting at though. Is can I forkIO but stay in my monad stack?
erisco 2017-02-21 05:39:47
it just exists to pass type arguments
erisco 2017-02-21 05:40:01
so it can literally be any f a
nitrix 2017-02-21 05:40:07
codedmart: (Also it's not higher-order, you're not giving a function to forkIO :P)
glguy 2017-02-21 05:40:40
codedmart: You certainly can't do that in general, but perhaps your particular monad stack is such that you could construct that operation
lyxia 2017-02-21 05:41:15
ph88: http://hackage.haskell.org/package/base-4.9.1.0/docs/Data-Typeable.html#v:eqT is a better equality function because it returns a witness.
ph88 2017-02-21 05:41:22
lyxia, ok in this case i would like to attempt using GHC.Generics and Typeable and if that doesn't work go for an alternative solution. What i would like to do is find the last T in a structure like Foo (Wrap T) (Bar (Wrap T)) (Wrap (Qux T)) and then change the value of it
ph88 2017-02-21 05:41:45
i don't know what a witness is in this context
kgadek 2017-02-21 05:41:51
nate__: https://gist.github.com/kgadek/1fcc4677f908693fa9401afd58b235c3
codedmart 2017-02-21 05:41:54
glguy: Hmm... This is what I have `ReaderT AppConfig (ExceptT ServantErr (LogM IO)) a`
ph88 2017-02-21 05:42:53
lyxia, hmm that function returns some extra information (i guess the actual witness? of type a :~: b ??)
lyxia 2017-02-21 05:42:57
ph88: By pattern matching on the witness, you allow the typechecker to unify the types that compare equal.
glguy 2017-02-21 05:43:01
codedmart: OK, so you'll need to write a function from that type to IO a
glguy 2017-02-21 05:43:32
and in that function you can decide how to handle if it results in an exception and what to do with the logging in the other thread
ph88 2017-02-21 05:43:56
lyxia, i can't really imagine this kind of pattern matching just yet, is that still using proxies ?