Search Haskell Channel Logs

Wednesday, February 1, 2017

#haskell channel featuring noan, jophish, nitrix, merijn, Andrea_, systadmin, and 9 others.

merijn 2017-02-01 03:48:21
right, so suppose I'm using xml-conduit to deal with some XML and I discover the XML is actually wrongly formatted...am I just SOL and need to switch to a different library?
merijn 2017-02-01 03:48:56
Because I don't think there's a way for me to fix/recover parse errors...
sm 2017-02-01 03:49:12
pretty-show++
quchen 2017-02-01 03:56:51
My show-prettyprint offers no inspection of Shown data, but the parser is more robust in my experiments: https://hackage.haskell.org/package/show-prettyprint
quchen 2017-02-01 03:57:10
Trifecta is a bit of a dependency though, so I only use it on larger projects
merijn 2017-02-01 04:01:43
Is there a haskell library for fixing up wrong XML?
ongy 2017-02-01 04:02:23
unlink? :)
Welkin 2017-02-01 04:02:27
wrong xml?
Welkin 2017-02-01 04:02:33
you mean a linter?
merijn 2017-02-01 04:03:03
Welkin: No, I mean retarded monkeys are generating invalid XML and I need to fix it so my xml parser can handle it
Welkin 2017-02-01 04:03:24
couldn't you use the output from an xml linter to do that?
merijn 2017-02-01 04:03:37
Welkin: Basically, they're not escaping quotes in attributes so you end up with:
merijn 2017-02-01 04:03:57
Welkin: Well, that leads to the question: Is there an xml-linting library for Haskell?
ystael 2017-02-01 04:05:09
merijn: oh god i'm so sorry
jophish 2017-02-01 04:07:39
merijn: It wouldn't be easier to get them to generate correct xml
jophish 2017-02-01 04:09:04
that was meant to be a question, but I suspect it works as a statement :|
lpaste 2017-02-01 04:21:30
Andrea pasted "state exercise" at http://lpaste.net/351876
Andrea_ 2017-02-01 04:23:08
the program worked fine with own defined state monad
Andrea_ 2017-02-01 04:23:19
but not with the library
Andrea_ 2017-02-01 04:24:41
what is the data constructor for State ?
nitrix 2017-02-01 04:25:25
StateT
Andrea_ 2017-02-01 04:26:04
i tried StateT
Andrea_ 2017-02-01 04:26:12
it doesn't work
nitrix 2017-02-01 04:27:47
I don't see the Identity monad in your lpaste.
lpaste 2017-02-01 04:27:55
Andrea pasted "No title" at http://lpaste.net/351877
Andrea_ 2017-02-01 04:28:25
this version with StateT
nitrix 2017-02-01 04:29:06
This version is supposed to give you two type errors.
nitrix 2017-02-01 04:29:16
For the implementation of pop and push.
nitrix 2017-02-01 04:29:37
As the result of the lambda is supposed to be monadic.
nitrix 2017-02-01 04:29:40
:t StateT
lambdabot 2017-02-01 04:29:42
(s -> m (a, s)) -> StateT s m a
nitrix 2017-02-01 04:30:03
`m (a, s)`. You have `(a, s)` as the resulting type.
Andrea_ 2017-02-01 04:30:46
i don't understand
Andrea_ 2017-02-01 04:32:40
this "pop = MS $ \(s:st) -> (st , s)" was my own defines State Monad (MState) this works
Andrea_ 2017-02-01 04:32:57
but the library version dosn't work
Andrea_ 2017-02-01 04:33:55
in my program first lpaste the data constructor is MS , in the library StateT ?
Andrea_ 2017-02-01 04:34:06
this doesn' work
Saizan_ 2017-02-01 04:35:28
Andrea_: you need "pop = StateT $ \(s:st) -> return (st , s)"
systadmin 2017-02-01 04:36:19
How does one find the last element in a list?
Andrea_ 2017-02-01 04:36:41
ok , thanks Saizan
Insanity_ 2017-02-01 04:37:02
> last [0..10]
lambdabot 2017-02-01 04:37:05
10
Insanity_ 2017-02-01 04:37:10
@systadmin, like that ^
lambdabot 2017-02-01 04:37:10
Unknown command, try @list
systadmin 2017-02-01 04:37:22
Oh, okay
Andrea_ 2017-02-01 04:39:23
hhm, the return statement is wrong the lambda expression has no return, the data constructor puts the lambda in the monad
Andrea_ 2017-02-01 04:42:06
ideas which data constructor in line 4 and line 7 ?
Saizan_ 2017-02-01 04:44:05
?type let pop = StateT $ \(s:st) -> return (st , s) in pop
lambdabot 2017-02-01 04:44:07
error:
lambdabot 2017-02-01 04:44:07
• Occurs check: cannot construct the infinite type: t1 ~ [t1]
lambdabot 2017-02-01 04:44:07
Expected type: m1 ([t1], [t1])
Saizan_ 2017-02-01 04:44:19
?type let pop = StateT $ \(s:st) -> return (s , st) in pop
lambdabot 2017-02-01 04:44:21
Monad m => StateT [a] m a
Saizan_ 2017-02-01 04:44:39
Andrea_: the s and st need to go in the other order
noan 2017-02-01 04:45:00
things like {-# LANGUAGE DeriveGeneric #-} are pre-processor directives essentially that import language features, whereas imports import libraries only, yes?