theelous3 2017-03-02 16:48:28
can someone help me wrap my head around how this is evaluated? let rightTriangles = [ (a,b,c) | c <- [1..10], b <- [1..c], a <- [1..b] ]
lyxia 2017-03-02 16:50:00
theelous3: are you familiar with nested for loops
theelous3 2017-03-02 16:50:05
I'd've presumed that, in order, we'd get say, [(1, 1, 1), (2, 2, 2) (etc.)], but we get [(1,1,1),(1,1,2) etc.]
theelous3 2017-03-02 16:50:11
ah
theelous3 2017-03-02 16:50:13
right
lyxia 2017-03-02 16:50:23
heh
theelous3 2017-03-02 16:50:24
so it evals the c's
theelous3 2017-03-02 16:50:58
gottcha I think
theelous3 2017-03-02 16:51:11
yeah makes sense
theelous3 2017-03-02 16:51:13
ty lyxia
lyxia 2017-03-02 16:51:21
yw
Nolrai 2017-03-02 16:57:27
So I am rather confused by this ghc error: http://lpaste.net/353164
Nolrai 2017-03-02 16:57:59
I am using FlexibleContexts, so why isn't it accepting the type it inffers?
mniip 2017-03-02 16:58:29
LANUAGE
Nolrai 2017-03-02 16:58:45
Oh god. Of course!
ertes 2017-03-02 16:59:15
Nolrai: it should have complained about an unknown pragma, too
cads 2017-03-02 16:59:17
Hey guys, I'm parsing some unformatted string output from an automated manufacturing service - basically these strings specify how much of which file needs to be manufactured, what material and thickness to use, and what finish to provide
cads 2017-03-02 16:59:24
Here's a sample: https://gist.github.com/maxsu/a64a5ad97c7f36591627abc7be311f21
lispy 2017-03-02 16:59:56
hello
cads 2017-03-02 17:00:04
there's some variability in the format, and I suspect that the format will continue to change as they tweak their code
Nolrai 2017-03-02 17:00:23
ertes: hmm. I don't think I've seen it ever make that complaint. Is there like a flag to turn that warnning on?
ertes 2017-03-02 17:00:47
Nolrai: not sure if a warning is needed, but i always use -W
cads 2017-03-02 17:00:53
so I'm wondering what's the best way to write a parser that will turn these unstructured strings into more tame structured json
lispy 2017-03-02 17:00:54
What sorts of projects are people working on these days?
lispy 2017-03-02 17:01:45
cads: well that's a pretty verbose english-y format
cads 2017-03-02 17:01:46
in practice it'll have to be fault tolerant enough to notify the admin when it can't parse a string
lispy 2017-03-02 17:02:14
But, since everything tends to be on online, you'd get pretty far with a regex as much as it pains me to suggest that
lispy 2017-03-02 17:02:22
er, on one line*
cads 2017-03-02 17:02:43
lispy, I was thinking regexes won
cads 2017-03-02 17:02:51
won't be too bad of an idea *
Nolrai 2017-03-02 17:04:17
ertes: stack build doesn't seem to be using the ghc-options in my .cabal file.
lispy 2017-03-02 17:04:55
cads: Actually, I might throw sed at it to preprocess into json, sexpr, csv, etc and then try to read that in
ezyang 2017-03-02 17:04:56
Nolrai: How can you tell?
lispy 2017-03-02 17:05:11
cads: Basically going with a design where I would decouple input massaging from the Haskell code
Nolrai 2017-03-02 17:06:08
From this? https://www.irccloud.com/pastebin/hOOo8mei/message_from_stack
glguy 2017-03-02 17:07:31
the ghc options wouldn't be passed to the setup executable
Nolrai 2017-03-02 17:08:28
Okay..so how do I tell then?
Nolrai 2017-03-02 17:11:50
Okay I think I solved this, I had a "ghc-options:" line for app and test, but not lib.
cads 2017-03-02 17:14:13
For a simple line like "1. qty 10, Custom part from R3J8-M0X4-aluspacer.dxf, Aluminum 6061 0.5, Process: Waterjet Machining," I can use a sed expression like 's/^[0-9]+\. qty \([0-9]\), Customer part from \(\w*.dxf\), \([^,]*\) \([0-9.]+\).*$/{"qty": "\1", "material": "\3", "thickness": "\4", "file": "\2"}/'
cads 2017-03-02 17:14:22
lispy, oh god that is so terrible, lol
Nolrai 2017-03-02 17:14:46
Does -W include warnings -Wall doesn't?
cads 2017-03-02 17:14:49
lemme see if that even works
MarcelineVQ 2017-03-02 17:16:15
Nolrai: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/using-warnings.html#options-sanity
lispy 2017-03-02 17:18:25
cads: it is pretty bad, but making a parser is going to have similar issues like, what is a token in this language? split on whitespace and punctuation, but then what about things like '-', you probably don't want to split on that.
Nolrai 2017-03-02 17:20:06
Hmm. It says "-Wunrecognised-pragmas" is on by default, but I am prettysure it shouldn't recognize "LANUAGE".
Nolrai 2017-03-02 17:20:59
lispy: using char as the tokens can work pretty well with haskell parsers.
cads 2017-03-02 17:22:29
lispy, that's true
Squarism 2017-03-02 17:23:00
why doesnt this work in ghci
Squarism 2017-03-02 17:23:03
Prelude> :{
Squarism 2017-03-02 17:23:03
Prelude| g :: Int -> String
Squarism 2017-03-02 17:23:03
Prelude| g i = show i
Squarism 2017-03-02 17:23:03
Prelude| :}
cads 2017-03-02 17:23:14
I guess I'm going to try it the regex way, but I'll probably do it in node or something more portable
Squarism 2017-03-02 17:23:20
get
Squarism 2017-03-02 17:23:21
cads 2017-03-02 17:23:38
Kinda wish I could just train the parser
lispy 2017-03-02 17:24:41
cads: if you want something more magical that might just work, there is this: http://www.padsproj.org/
monochrom 2017-03-02 17:25:04
Squarism: I just tried. Works.
Squarism 2017-03-02 17:25:09
gah
cads 2017-03-02 17:25:56
lispy, a concern is that this will have to be fault tolerant - if the data producer changes its format and the parser can't make sense of the new format, it needs to tell the human operator "hey, the format has changed"
cads 2017-03-02 17:26:29
I'll have to see about making an agreement for the producer to not change the format without notice
lispy 2017-03-02 17:26:38
ah
lispy 2017-03-02 17:26:51
Yeah, that means regular expressions are a liability
lispy 2017-03-02 17:27:31
If you're open to trying new things (I assumed this needed to be in Haskell), then PADS is probably the best tool I can think of
cads 2017-03-02 17:27:38
already in the three months of data I'm working with I've seen the data format change a bit, and there are also entries which seem hand written
cads 2017-03-02 17:27:45
lispy, checking pads out right now
lispy 2017-03-02 17:28:14
looks like there is a Haskell backend
cads 2017-03-02 17:28:33
lol, I'm only asking in here because I know haskellites have been exposed to advanced parser generation techniques :)
cads 2017-03-02 17:28:52
but yeah, this is probably going to be written in node or python
lispy 2017-03-02 17:29:33
cads: like this example is kind of cool: http://pads.cs.tufts.edu/examples.html
lispy 2017-03-02 17:29:40
they generate C code that can parse the example log format
lispy 2017-03-02 17:29:46
You could call C code from python
cads 2017-03-02 17:30:47
yeah, shouldn't be a problem
lispy 2017-03-02 17:31:16
http://pads.cs.tufts.edu/doc/tutorial.html#toc11
Nolrai 2017-03-02 17:33:23
what do ":{" and ":}" mean in ghci?
lyxia 2017-03-02 17:33:40
start and end a multiline section
Nolrai 2017-03-02 17:33:51
Ah.
jle` 2017-03-02 17:43:10
Squarism: what version of ghc are you using?
jle` 2017-03-02 17:43:21
Squarism: in versions before 8.0, you aren't allowed to define functions like that
Squarism 2017-03-02 17:43:23
jle`, 7.10
jle` 2017-03-02 17:43:26
ah yeah
Squarism 2017-03-02 17:43:35
i figured it out though
jle` 2017-03-02 17:43:37
prior to ghci 8.0 functions have to be defined using 'let'
jle` 2017-03-02 17:43:47
this has always caused a lot of confusion
Squarism 2017-03-02 17:44:07
had to do:
Squarism 2017-03-02 17:44:08
*JC.Facade.Console.Controller> :{
Squarism 2017-03-02 17:44:08
*JC.Facade.Console.Controller| let g :: Int -> String
Squarism 2017-03-02 17:44:08
*JC.Facade.Console.Controller| g i = show i
Squarism 2017-03-02 17:44:08
*JC.Facade.Console.Controller| :}
jle` 2017-03-02 17:44:18
yeah, you have to 'let' function declarations
jle` 2017-03-02 17:44:28
glad they finally got rid of that requirement
Squarism 2017-03-02 17:44:54
i really have no good reason beeing on 7.10 still as im using stack
Squarism 2017-03-02 17:45:05
but just havent gotten to it