dolio 2017-02-03 10:45:12
I don't think so. Putting an object name in like that is common.
dolio 2017-02-03 10:46:12
Like, if F(g,h) is `bimap g h`, F(C,h) is how `second h` is written.
dolio 2017-02-03 10:47:14
second@C h
nitrix 2017-02-03 10:47:38
merijn: In my implementation (this is very old and I was new to Haskell), a Link would look like this:
nitrix 2017-02-03 10:48:12
merijn: data Link = MkLink { linkId :: Integer, linkRef :: IORef (Maybe (Weak (IORef a))) }
nitrix 2017-02-03 10:48:43
merijn: All the functions to manipule the links would have this Linkable constraint: type Linkable a = (Typeable a, FromJSON a, ToJSON a)
pikajude 2017-02-03 10:48:46
where does the `a` come from?
nitrix 2017-02-03 10:49:05
Sorry, add the `a` parameter, my bad.
merijn 2017-02-03 10:49:43
nitrix: ah, I think the problem with mimicing that is that my datatypes are generated by persistent and backed by an SQL database.
merijn 2017-02-03 10:50:05
nitrix: So I can't copy that approach. And I'm pretty sure persistent can do what I want, I'm just not sure how :p
nitrix 2017-02-03 10:50:32
merijn: The idea is that a Link would contain the id of a resource, and as the application was resolving dependencies between things that are linked, it'd load from disk the data and update the IORef.
nitrix 2017-02-03 10:51:14
merijn: I don't loose type information :/
nitrix 2017-02-03 10:52:12
I had an interesting system that'd maintain only the N most recently used resources and unload the ones not needed, hence the Weak pointer.
nitrix 2017-02-03 10:52:31
Essentially, lazy relations x]
nitrix 2017-02-03 10:53:20
It was quite the idea. I've had multiple iterations. The latest is the most sane, and it lets you chose the storage of your choice, but I'm still not ready to publish it.
nitrix 2017-02-03 10:53:42
It has a cute monad transformer too :D
nitrix 2017-02-03 10:55:10
gameState @> player @> inventory @> money %~ (+100)
nitrix 2017-02-03 10:55:52
Where that player is a Link Player. Multiple things in the game would use this Link Player instead of the actual Player. Like the word map, guilds, friend lists, etc.
pikajude 2017-02-03 10:56:06
Link Player, lol
nitrix 2017-02-03 10:56:49
Laugh all you want. When you'll need to figure out how to do O(1) relational data in Haskell I'll be the one laughing :P
merijn 2017-02-03 10:56:52
nitrix: Yeah, but I'm using SQLite anyway for persistence reasons :)
pikajude 2017-02-03 10:58:38
nitrix: this sounds like a great setup to make a Zelda game in Haskell
nitrix 2017-02-03 10:59:24
The newer version uses the names Cell, Relation and Relational.
nitrix 2017-02-03 11:00:02
I haven't looked at it in a while but it's much less ridiculous, I agree.
jophish 2017-02-03 11:00:35
Are there any nice high-level libraries for shared memory between processes?
merijn 2017-02-03 11:01:09
jophish: I don't think any amount of high-level can make that nice... :)
nitrix 2017-02-03 11:01:20
readLink :: Linkable a => Context -> Link a -> IO (Maybe a)
nitrix 2017-02-03 11:01:46
merijn: O(log n) first read, O(1) for subsequent reads and writes.
jophish 2017-02-03 11:01:51
merijn: you're probably right. It should be possible to go beyond "here's a buffer, deal with it"
merijn 2017-02-03 11:02:03
jophish: What's the end goal?
nitrix 2017-02-03 11:03:27
merijn: The problem with all of it is that after trying to make it pure, removing the IO, using dirty hacks, infinite lists, time varying functions, I had basically re-created FRP.
nitrix 2017-02-03 11:03:40
Hence why I was so interested in it and why I bring it up often.
jophish 2017-02-03 11:03:56
merijn: Some short lived processes which need to pass some information back to a long lived master process
jophish 2017-02-03 11:04:14
a linux fifo might be best
merijn 2017-02-03 11:04:55
jophish: Yeah, go with a pipe, IMO
merijn 2017-02-03 11:05:24
Way easier to deal with
jophish 2017-02-03 11:05:25
I think I got carried away trying to think of a nice way to handle a shared buffer in haskell :)
merijn 2017-02-03 11:07:08
jophish: I'm still working on high-level mmap for haskell :p
merijn 2017-02-03 11:07:42
Because mmap == best syscall :D
jophish 2017-02-03 11:10:02
It is a pretty good one
merijn 2017-02-03 11:11:06
mmap is like compilers in terms of tools, when you know it everything starts to look like an mmap/compiler problem ;)
pikajude 2017-02-03 11:11:59
everything can be reimplemented in terms of mmap
Gurkenglas 2017-02-03 11:13:33
Can I make stack ghci hide the import list? Can I make it keep the stuff I import imported?
Gurkenglas 2017-02-03 11:13:40
*between sessions
merijn 2017-02-03 11:15:01
Gurkenglas: You can import stuff in a .ghci file that gets run automatically
merijn 2017-02-03 11:15:23
Gurkenglas: For example: https://github.com/merijn/dotfiles/blob/master/dotfiles/ghci
Gurkenglas 2017-02-03 11:15:51
I put that in the global project, I guess?
merijn 2017-02-03 11:16:00
Gurkenglas: I have no clue about stack
merijn 2017-02-03 11:16:06
Gurkenglas: I just have that in ~/.ghci
erisco 2017-02-03 11:23:06
why not coeffects, sigh
erisco 2017-02-03 11:23:09
then this would be trivial
erisco 2017-02-03 11:23:53
I am serious when I say it is one of the best ideas for practical programming
erisco 2017-02-03 11:24:04
solves so many headaches
Lokathor 2017-02-03 11:24:11
i don't know what coeffects are
Lokathor 2017-02-03 11:24:21
and i have a throbbing headache from sickness
Lokathor 2017-02-03 11:24:30
a test: can you still get me to understand them?
erisco 2017-02-03 11:24:35
http://tomasp.net/coeffects/
Lokathor 2017-02-03 11:24:56
we'll call that a "soft fail"
Lokathor 2017-02-03 11:25:20
you tried hard, but were beaten by the afore mentioned throbbing headache alsmost as soon as i opened the page and saw how much text there is
erisco 2017-02-03 11:25:48
the TLDR is free variables become part of the type
Lokathor 2017-02-03 11:25:55
oh cool
erisco 2017-02-03 11:25:56
known as the context
Lokathor 2017-02-03 11:26:06
burritos are like a context
Lokathor 2017-02-03 11:26:14
;3
nitrix 2017-02-03 11:26:32
A delicious context.
erisco 2017-02-03 11:27:38
so now you can easily write code in a sort of ad hoc generic manner
monochrom 2017-02-03 11:28:21
What is coeffect?
erisco 2017-02-03 11:28:27
DI, dictionaries, type classes ... all these things can be used like that
Lokathor 2017-02-03 11:28:43
DI = Directional Influence, right?
erisco 2017-02-03 11:28:56
dep injection
erisco 2017-02-03 11:29:06
IoC also relevant
Lokathor 2017-02-03 11:29:26
does one even do dependency injection outside of an OO context?
erisco 2017-02-03 11:29:54
monochrom, I think it is a bit of a play with words
Gurkenglas 2017-02-03 11:30:05
:t [undefined :: AnIso s t a b, undefined :: Optic (Costar f) g s t a b, _Unwrapping Sum] -- Removing either of the first two makes this well-typed. (They are the types of the first arguments of au and auf.) Why isn't this well-typed?
lambdabot 2017-02-03 11:30:07
error:
lambdabot 2017-02-03 11:30:07
• Couldn't match type 'Control.Lens.Internal.Iso.Exchange
lambdabot 2017-02-03 11:30:07
(Sum b) (Sum b1) (Sum b) (Identity (Sum b1))'
erisco 2017-02-03 11:30:13
Lokathor, absolutely. That is what dicts and Reader and so on are about
erisco 2017-02-03 11:30:19
and TCs are used for this sometimes
erisco 2017-02-03 11:30:44
different mechanism than in OO but same idea
Lokathor 2017-02-03 11:30:56
ah hmm
erisco 2017-02-03 11:31:31
monochrom, I think loosely they mean that effects come out and coeffects go in
erisco 2017-02-03 11:32:22
the PITA with Reader is now you're committed to Monad
erisco 2017-02-03 11:32:41
and while do-notation helps a bunch it still isn't as pleasant as not needing it at all
Gurkenglas 2017-02-03 11:33:00
"If the device visiting your client/server application does not have clock, the coeffect can use clock available from the server." <- you accidentally article
Jello_Raptor 2017-02-03 11:33:01
What should I call the following? `newtype Foo a b c = (Monad a, Monad b) => Foo { getFoo :: a (c,b ())}` which has the instance `k >>= f = Foo $ do { (v,d) <- k ; (v',d') <- f v ; return (v', d >> d'); }` ?
Jello_Raptor 2017-02-03 11:33:52
basically, run one monad that sends out "instructions" in another monad that are all chained together?
Gurkenglas 2017-02-03 11:34:15
Looks like a writer monad with the monoid being outputless monad actions
Jello_Raptor 2017-02-03 11:34:27
yup, pretty much
Jello_Raptor 2017-02-03 11:35:23
is there some straightforward way to construct that out of a writer? (a newtype wrapper that gives me a monoid instance using ">>")
monochrom 2017-02-03 11:35:38
Interesting, erisco.
Gurkenglas 2017-02-03 11:36:17
So I'd do `newtype Foo m = Foo { getFoo :: m () }`, give "Monad m => Foo m" a monoid instance, and use WriterT (Foo b) a c
Jello_Raptor 2017-02-03 11:37:42
still needs a name though. :P
Gurkenglas 2017-02-03 11:38:35
"Silent"? "Scribing"? *looks though ekmett's libraries*
Jello_Raptor 2017-02-03 11:38:54
Scribe is pretty good
merijn 2017-02-03 11:39:58
Is there like a yesod/persistent channel?
rblaze 2017-02-03 11:40:02
is there any runtime difference between newtype Foo = Foo String and newtype Foo = Foo { unFoo :: String }? I'm not sure about record layout in haskell.
Gurkenglas 2017-02-03 11:40:07
That'd be for the ($()) Foo of course, not your first - that one is emergent enough not to deserve a simple name
Jello_Raptor 2017-02-03 11:40:09
yes it does if I swap the arguments
merijn 2017-02-03 11:40:45
rblaze: No
merijn 2017-02-03 11:40:59
rblaze: Well, there is a difference in that the letter will generate an accessor for you
merijn 2017-02-03 11:41:09
rblaze: But no difference in memory
erisco 2017-02-03 11:41:28
if you've ever seen the dreaded x = y; f(); calling convention, coeffects is actually a bit like that but typed (and no mutation in a pure lang of course)
merijn 2017-02-03 11:41:29
s/letter/latter
erisco 2017-02-03 11:42:21
the reason you're seeing that convention, at least when used most intelligently, is because there is then a series of calls all using the same assignment
Jello_Raptor 2017-02-03 11:42:21
Gurkenglas: mhmm
erisco 2017-02-03 11:42:31
*cough* OpenGL
rblaze 2017-02-03 11:43:01
merijn: thanks. Do you know any short doc on records implementation? I'd like to learn a bit about it.
Gurkenglas 2017-02-03 11:43:11
(except for those names applications can always use like "GameState" and "MyApp")
merijn 2017-02-03 11:43:28
rblaze: Records aren't really different from non-records
merijn 2017-02-03 11:43:45
rblaze: IN fact, you can use non-record pattern matching on records and vice versa
merijn 2017-02-03 11:44:06
@define data Foo = Foo { unFoo :: String } deriving (Show)
lambdabot 2017-02-03 11:44:08
Defined.
merijn 2017-02-03 11:44:16
> let x = Foo "test" in x
lambdabot 2017-02-03 11:44:20
Foo {unFoo = "test"}
merijn 2017-02-03 11:44:25
> let Foo x = Foo "test" in x
lambdabot 2017-02-03 11:44:27
"test"
monochrom 2017-02-03 11:44:38
rblaze: The Haskell 2010 Report describes the record syntax completely. It is a fairly shallow syntax sugar.
merijn 2017-02-03 11:44:48
> case Just True of Just{} -> 'a'; Nothing -> 'b'
lambdabot 2017-02-03 11:44:50
'a'