Search Haskell Channel Logs

Friday, February 3, 2017

#haskell channel featuring jophish, ocharles, nhooyr, danza, quchen, simli,

nhooyr 2017-02-02 22:45:32
in yesod, does the development server automatically refresh the page in the browser when a file is changed? like say I edit some html file, template, or whatever, is the page itself reloaded in the browser?
tfc 2017-02-02 22:54:54
hi there. i am going to implement some kind of config file support for my haskell app. i have seen that there are multiple libraries. can someone tell me which library seems to be the most dependable regarding stability, usability and futureproofness?
simli 2017-02-02 22:56:39
I have a typeclass TypedMessage a where messageType :: a -> MessageType. All instances define this as messageType _ = SomeKindOfMessage. Is there some way I can call this without having an instance of a?
simli 2017-02-02 22:57:55
I'd like to make a function which does not need to know the constructors of a but still can get this information, it's part of a serialization thing
simli 2017-02-02 22:59:41
nhooyr: it's been a while, but I think not. However, if you access the page before the dev server is ready, I think it does, like you get a page saying drink some water, breathe, etc while waiting
quchen 2017-02-02 23:00:39
simli: We usually use Proxy for that
quchen 2017-02-02 23:00:55
class TypedMessage a where messageType :: Proxy a -> MessageType
quchen 2017-02-02 23:01:06
messageType _ = SomeKindOfMessage
quchen 2017-02-02 23:01:33
You can create a »Proxy a« for any »a«
nhooyr 2017-02-02 23:01:59
simli: ah, so only the first time, when you first start the dev server does it reload. otherwise nope?
quchen 2017-02-02 23:02:03
Use e.g. as »messageType (Proxy :: Proxy Foobar)« to get the message type associated to »Foobar«.
jophish 2017-02-02 23:02:19
tfc: What I do is just use yaml
jophish 2017-02-02 23:02:29
and derice FromJSON to get a parser
jophish 2017-02-02 23:02:32
derive*
tfc 2017-02-02 23:02:56
jophish: that one: https://hackage.haskell.org/package/yaml-0.8.21.2 ?
jophish 2017-02-02 23:03:09
tfc: yeah, I'll post an example of my code
tfc 2017-02-02 23:03:19
jophish: oh an example would be great.
jophish 2017-02-02 23:03:52
tfc: It's probably a little more complicated than it needs to be
tfc 2017-02-02 23:04:18
jophish: no problem, any help is great.
simli 2017-02-02 23:04:26
nhooyr: I think so, yes
danza 2017-02-02 23:04:35
i love Haskell because in order to improve my program i need to study for 10 minutes what an applicative is, then i change two lines of code and everything works as expected <3 <3 <3
nhooyr 2017-02-02 23:04:37
simli: cool thanks :D
simli 2017-02-02 23:05:35
quchen: I'll read up on that, thanks :)
jophish 2017-02-02 23:06:24
Here is the 'Config' type: https://github.com/hercules-ci/hercules/blob/master/backend/src/Hercules/Config.hs The strange FromJSON code is to strip 'config' from the beginning of each field (this can do exactly that job and I should switch over https://hackage.haskell.org/package/aeson-casing-0.1.0.5/docs/Data-Aeson-Casing.html). Here is the config file https://github.com/hercules-ci/hercules/blob/master/
jophish 2017-02-02 23:06:30
backend/example-config.yaml And here is a command line parser https://github.com/hercules-ci/hercules/blob/master/backend/app/Main.hs
jophish 2017-02-02 23:06:53
tfc: The command line parser takes either '-c YAML' and loads the config from a yaml description, or takes all the options on the command line
tfc 2017-02-02 23:07:27
jophish: cool thx. btw the https://github.com/hercules-ci/hercules/blob/master/ link does not work
jophish 2017-02-02 23:07:53
tfc: It got split between two messages on IRC
jophish 2017-02-02 23:08:03
tfc: this might be the interesting part for you https://github.com/hercules-ci/hercules/blob/master/backend/app/Main.hs#L25-L27
tfc 2017-02-02 23:08:10
ah yes i see the split, oops. :D
jophish 2017-02-02 23:08:13
This takes a filename and parses it as yaml into a 'Config'
tfc 2017-02-02 23:08:59
ok, i will back down in my coding chamber and study your code. i hope it does not disturb you if i come back with questions later.
jophish 2017-02-02 23:09:13
sure, I'll answer if I'm around
tfc 2017-02-02 23:09:18
cool thx
ph88 2017-02-02 23:22:11
hello
jophish 2017-02-02 23:23:18
tdammers: is casing on github?
ocharles 2017-02-02 23:24:28
Hmm, this question raises a good point (https://stackoverflow.com/questions/42016605/haskell-implement-unix-touch-command): "The documentation for openFile states that: If the file does not exist and it is opened for output, it should be created as a new file."
ph88 2017-02-02 23:24:46
could anyone explain me this "could not deduce" error ? https://paste.fedoraproject.org/544464/86117456/
ocharles 2017-02-02 23:24:57
Yet the documentation for openFile *also* states: This operation may fail with: ..., isDoesNotExistError if the file does not exist;"
ph88 2017-02-02 23:25:01
hi ocharles
ocharles 2017-02-02 23:25:03
So... which is it `base`~?
ocharles 2017-02-02 23:25:04
!?
ocharles 2017-02-02 23:25:05
:)
ocharles 2017-02-02 23:25:07
Hi ph88
ph88 2017-02-02 23:25:14
i got the generic stuff working :)
ocharles 2017-02-02 23:25:33
Oh, I guess the documentation isn't conflicting, because it only creates the file if you try open it for output, but won't be created for input.
ocharles 2017-02-02 23:25:35
Duh
ocharles 2017-02-02 23:25:38
ph88: fantastic! Can I see?
ph88 2017-02-02 23:25:42
yes sure
ph88 2017-02-02 23:26:13
ocharles, https://paste.fedoraproject.org/544468/48611756/
ph88 2017-02-02 23:27:04
in the end i needed to make more instances like on line 56 and 57 all the way up to a 6-tuple
ocharles 2017-02-02 23:29:36
Cool, glad it worked out :)
ph88 2017-02-02 23:31:03
:)
ph88 2017-02-02 23:36:24
ocharles, now that you're here, do you know perhaps why i get that could not deduce error ?
ocharles 2017-02-02 23:37:19
Well, you wrote "trace ("DecimalLiteral return " ++ d1 ++ dz ++ ex) (d1 ++ dz ++ ex)" - that second argument is a list, no?
ocharles 2017-02-02 23:37:39
trace :: Decorator [] => String -> [a] -> [a], but there is no Decorator [] instance in your paste
simli 2017-02-02 23:39:28
quchen: Proxy seems spot on with what I want to do, but I get inference errors if I try to use a type parameter from the function signature. like messageType (Proxy :: Proxy a) where a is constrained to TypedMessage a
ph88 2017-02-02 23:39:39
ocharles, that second argument is a list of Char, since d1 and dz and ex are of type String
ocharles 2017-02-02 23:40:11
ph88: ok, but how does that change anything? It's still a list, and there is no instance for lists, regardless of what they are lists of
ocharles 2017-02-02 23:40:27
ph88: put it another way, which instance do you think you have provided that is sufficient that GHC shouldn't complain?
simli 2017-02-02 23:40:28
is this not possible, or am I missing something else? ghc claims the type is ambigous between all the instances of TypedMessage
ocharles 2017-02-02 23:40:55
simli: can you share any code? (Please use a pastebin)
ph88 2017-02-02 23:41:38
ocharles, ah i am in the list monad, but why? i expect to be either in the Parser or in the Gen monad
ph88 2017-02-02 23:42:21
not that i have solid base for that expectation, but i'm still surprised that it isn't so
ocharles 2017-02-02 23:42:53
ph88: that let binding still uses [Char] as its second argument, that is the source of your problem
ocharles 2017-02-02 23:43:46
Maybe you want to trace (...) (return (d1 ++ dz ++ ex) :: Parser String) or something
ocharles 2017-02-02 23:44:08
But then you try and pack the result, which means it has to be a string, so that next line isn't going to type check
ph88 2017-02-02 23:44:15
hmmz