Search Haskell Channel Logs

Saturday, March 4, 2017

#haskell channel featuring Squarism, nmattia, hexagoxel, Mortenl,

hexagoxel 2017-03-04 00:47:23
Squarism: Dynamic/existential type/unsafeCoerce are your options
Squarism 2017-03-04 00:49:12
hexagoxel, Ok thank you. Im not sure if you describe 1/2/4 concepts?
hexagoxel 2017-03-04 00:49:37
Squarism: Dynamic/(existential type)/unsafeCoerce
hexagoxel 2017-03-04 00:50:00
what is SomeClass?
hexagoxel 2017-03-04 00:50:18
if the existential makes sense depends on that.
hexagoxel 2017-03-04 00:51:00
(you'd have data SomeInstance = forall a . SomeClass a => SomeInstance a and TChan SomeInstance)
Squarism 2017-03-04 00:54:05
hexagoxel, SomeClass would be just be a collection of "traits" for a certain type of message
Squarism 2017-03-04 00:54:59
Really it should be a type parameter
Squarism 2017-03-04 00:55:20
(rambling)
Squarism 2017-03-04 00:56:06
Really it should be a Java style type parameter. But i dont know how to express such
hexagoxel 2017-03-04 00:56:40
i am not convinced that what you have in mind would not be a (inefficient/bad) emulation of a union type.
hexagoxel 2017-03-04 00:58:31
i think example code would help.
Squarism 2017-03-04 01:03:25
hexagoxel, http://lpaste.net/353204
Squarism 2017-03-04 01:03:33
thats my sketch so far.
Squarism 2017-03-04 01:04:47
its basicall about launching games (that have their own messageing model) depending on a "GameType" parameter found in the database - for a gameid parameter given by a connecting client. I have htis all working for one game.
Squarism 2017-03-04 01:05:11
but i want to make it generic so i can have the same gameloop/messaging code for all games
Squarism 2017-03-04 01:06:45
launch game would creat a gameAdapter and just invoke gameLoop. The hard part constructing these typed channels and storing them in one MVar
hexagoxel 2017-03-04 01:13:48
Squarism: i think you can use an existential without any constraint/any additional type class. Something in the direction of GameServerInstance = forall m1 m2 . GameServerInstance (GameAdapter m1 m2) (TChan m1) (TChan m2)
hexagoxel 2017-03-04 01:14:44
that way you can have a monomorphic list of instances, yet when matching on a specific, you know that the types match up.
Squarism 2017-03-04 01:17:48
hexagoxel, so you mean my MVar should be typed with GameServerInstance?
Squarism 2017-03-04 01:19:38
(ive never used existential types in haskell)
hexagoxel 2017-03-04 01:21:40
Squarism: yes, probably. the code does not show yet how you use the MVar.
hexagoxel 2017-03-04 01:22:05
Squarism: maybe consider the two examples at 3.2 on https://wiki.haskell.org/Existential_type
hexagoxel 2017-03-04 01:22:37
(hmm are there no better explained examples of existential without constraints around?)
Squarism 2017-03-04 01:23:27
ill take a deep look into the hint you've given me
Squarism 2017-03-04 01:23:54
hexagoxel, thanks alot
Squarism 2017-03-04 01:24:45
...ill prolly need to read up on how they are used to persue this
Mortenl 2017-03-04 01:32:08
Is there any work going on to bring scoped threads back into the standard library? They're pretty nice
nmattia 2017-03-04 01:32:50
hi guys, I'm looking for some advice. I have a cabal project that builds an executable. the test-suite contains integrations tests that use the produced executable. with stack everything is fine, since it'll build the executable first and then put it on the path. however I'm struggling with nix, because I can't really pass the result of the derivat
nmattia 2017-03-04 01:32:50
ion as a build input to the derivation itself
nmattia 2017-03-04 01:33:47
one solution would be to skip the checkPhase, though it's a bit hacky
hexagoxel 2017-03-04 01:35:19
Squarism: https://hackage.haskell.org/package/foldl-1.2.3/docs/Control-Foldl.html#t:Fold seems like a nice real-life example of a non-typeclass existential.
hexagoxel 2017-03-04 01:35:38
note that there is an implicit "forall x ."
hexagoxel 2017-03-04 01:36:26
and with some creative imagination, a game is just a Fold over some game state :)