Search Haskell Channel Logs

Wednesday, March 8, 2017

#haskell channel featuring biglama, Cale, brynedwards, wizard1337, errorondefault_,

Cale 2017-03-07 21:59:45
wizard1337: ??
Cale 2017-03-07 22:00:07
oh, Glorious Glasgow Haskell Compiler? :)
errorondefault_ 2017-03-07 22:06:44
and i really want this job :D
wizard1337 2017-03-07 22:07:06
that's code for "i'm not qualified"
wizard1337 2017-03-07 22:07:33
seriously though asking other people about job interview questions is really bad,
errorondefault_ 2017-03-07 22:07:36
well im not :D Im second semester but Im eager to learn ;)
Cale 2017-03-07 22:07:43
anyway, if you have questions regarding the programming language Haskell, I'm sure people here would be happy to help
wizard1337 2017-03-07 22:07:49
because if you advance to the next step,
Cale 2017-03-07 22:07:52
Otherwise, it's not really the right place
wizard1337 2017-03-07 22:08:03
you'll waste their time in that step
wizard1337 2017-03-07 22:08:08
rather than now
errorondefault_ 2017-03-07 22:08:13
ok youre right sorry about that
wizard1337 2017-03-07 22:08:22
and subsequent steps often involve actually interviewing at a whiteboard etc
Cale 2017-03-07 22:08:27
wizard1337: pls
errorondefault_ 2017-03-07 22:08:43
thanks anyways guys
wizard1337 2017-03-07 22:09:10
no etquiette allowed? even functional etiquiette?
wizard1337 2017-03-07 22:09:38
i resolved his "haskell question"
biglama 2017-03-07 22:11:08
hi guys, I would like to use HStringTemplate with a custom datatype
biglama 2017-03-07 22:11:27
but one of the field of my datatype is another datatype and I would like to have a custom show for this field
biglama 2017-03-07 22:11:55
I've tried to instantiate ToSElem and Show but it still resort to the default show
biglama 2017-03-07 22:30:48
Cale: GenericStandard avoid to define ToSElem instances actually. But then I would have to define a ToSElem instance for person too ?
Cale 2017-03-07 22:31:02
Possibly, yes
brynedwards 2017-03-07 22:31:35
The StringTemplate docs have "class Show a => StringTemplateShows a where"
brynedwards 2017-03-07 22:32:04
Which takes and optional format string, and its default is show. Have you tried instantiating that?
Cale 2017-03-07 22:32:56
ah, you'd be using the ToSElem instance for Person as it stands
Cale 2017-03-07 22:33:58
Since you're doing setAttribute with a Person value
biglama 2017-03-07 22:34:39
brynedwards: I've tried but I'm a bit confused between ToSElem and StringTemplateShows
Cale 2017-03-07 22:35:59
So if that instance is just based on the Data.Data generic representation entirely, it won't do what you want.
biglama 2017-03-07 22:36:21
I do not need the format string so I though instantiang ToSElem would be enough
Cale 2017-03-07 22:36:21
Try just writing a ToSElem instance for Person
brynedwards 2017-03-07 22:36:21
Yeah but it says the format string is optional so maybe it uses it regardless
Cale 2017-03-07 22:36:21
You're not actually using the ToSElem instance for Children at all, iiuc
Cale 2017-03-07 22:36:21
(you should be able to comment out / delete that instance and still have the program build if I'm right)
Cale 2017-03-07 22:37:16
Personally, I avoid libraries like this. Usually it's easy enough just to concatenate strings together the way you want, and do whatever formatting is necessary in-place with whatever functions are appropriate.
Cale 2017-03-07 22:38:33
(Though, I couldn't help writing one of them anyway ;) https://hackage.haskell.org/package/category-printf
biglama 2017-03-07 22:39:51
Cale: here is a trimmed-down example with juste an instance of ToSElem, but it does not work
biglama 2017-03-07 22:39:54
Cale: http://lpaste.net/6884328818773852160
biglama 2017-03-07 22:40:09
I'm trying with an instance of StringTemplateShows now
Cale 2017-03-07 22:40:21
What happens? You get a complaint that the name and children fields aren't present?
biglama 2017-03-07 22:40:25
Cale: well, I wanted something clean :)
biglama 2017-03-07 22:40:45
Cale: the code runs but the output is empty for the field, as in
biglama 2017-03-07 22:40:47
"Your full name is , children = ."
Cale 2017-03-07 22:40:51
nice
Cale 2017-03-07 22:41:04
I suspect that's what the SMap constructor is for
Cale 2017-03-07 22:41:38
Actually, I would throw this library out on the spot for producing that output rather than an error of some sort.
biglama 2017-03-07 22:42:08
:)
biglama 2017-03-07 22:42:27
How would SMap play a role here ? I'm looking at the code but don't see where it's used
Cale 2017-03-07 22:42:39
Well, where you're currently producing a STR
Cale 2017-03-07 22:43:00
You want the person thing to have some named subfields which you refer to in your template
Cale 2017-03-07 22:43:15
So, presumably there's some way to define what those expand to
Cale 2017-03-07 22:43:37
and if you look at the SElem type
Cale 2017-03-07 22:44:07
The only thing which looks like it could be doing that job is the SM constructor which takes an "SMap a"
Cale 2017-03-07 22:44:21
and apparently type SMap a = Map String (SElem a)
Cale 2017-03-07 22:44:44
So I'd expect that to be a Map from the "field names" to how to format them.