Search Haskell Channel Logs

Saturday, March 4, 2017

#haskell channel featuring bollu, lpaste_, cocreature, tsahyt, Nikola, sbrg,

bollu 2017-03-04 04:51:41
I fail to understand how the Iso instance of lens is encoded using PRofunctots
bollu 2017-03-04 04:51:44
Profunctors
bollu 2017-03-04 04:51:58
I'm reading lens over tea, but I'm confused as to how the method makes sense
bollu 2017-03-04 04:52:05
could someone walk me through this?
johnw 2017-03-04 04:52:34
hi bollu
johnw 2017-03-04 04:52:48
consider this function: iso :: (s -> a) -> (b -> t) -> Iso s t a b
bollu 2017-03-04 04:54:16
johnw: yes
bollu 2017-03-04 04:54:24
johnw: what repr. of Iso are you using? :)
johnw 2017-03-04 04:54:40
type Iso s t a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p s (f t)
bollu 2017-03-04 04:55:25
johnw: I want to know where that came from
bollu 2017-03-04 04:55:29
johnw: but do go on
johnw 2017-03-04 04:55:30
Control.Lens.Iso
johnw 2017-03-04 04:55:38
note that if we use (->) as our profunctor, it becomes the type of Lens
bollu 2017-03-04 04:56:38
johnw: yep
johnw 2017-03-04 04:56:39
by another choice, we get the type of Prism
bollu 2017-03-04 04:56:59
John[Lisbeth]: I meant, like, "how did we arrive at that representation, and how does it represent isomorphisms" ?
bollu 2017-03-04 04:57:05
johnw: what is the other choice?
bollu 2017-03-04 04:57:08
johnw: ^
bollu 2017-03-04 04:57:18
John[Lisbeth]: sorry for the ping!
johnw 2017-03-04 04:57:42
this: Iso s t a b ~ (s -> a, b -> t)
johnw 2017-03-04 04:57:49
as you saw in the over tea article
bollu 2017-03-04 04:58:24
johnw: yes, that's the part I'm iffy about. I don't understand the "enum "example
bollu 2017-03-04 04:58:45
johnw: I am able to create a function called "enum_rev" like so: https://github.com/neongreen/artyom.me/issues/18
bollu 2017-03-04 04:58:53
but according to the article, I should not be able to do so?
bollu 2017-03-04 04:59:11
johnw: https://artyom.me/lens-over-tea-4
berkobra 2017-03-04 04:59:34
hello everyone
bollu 2017-03-04 04:59:38
berkobra: hey
berkobra 2017-03-04 04:59:59
i am a newbie trying to tackle project euler problems
berkobra 2017-03-04 05:00:11
but I got a parse error in my code
berkobra 2017-03-04 05:00:14
http://lpaste.net/353208
berkobra 2017-03-04 05:00:18
can you have alook :)
bollu 2017-03-04 05:00:38
johnw: could you please take a look? :)
johnw 2017-03-04 05:00:47
bollu: actually, this article really lays it out quite well, so maybe #haskell-lens is a better place to ask for the deeper theory. I don't know how they came up with the exact definition we have for Iso.
bollu 2017-03-04 05:02:06
johnw: did you read my issue?
bollu 2017-03-04 05:02:15
johnw: it's like, I'm stuck on a par
bollu 2017-03-04 05:02:24
johnw: I did ask on #haskell-lens, but it seems dead :(
johnw 2017-03-04 05:02:24
I did, but I'm afraid I don't have the time to dig into this deeply right now
bollu 2017-03-04 05:02:31
johnw: I see. thanks anyway :)
bollu 2017-03-04 05:02:38
johnw: much appreciated
johnw 2017-03-04 05:03:31
in your enum_rev example, btw
johnw 2017-03-04 05:03:44
what happens if I .~ an integer that toEnum fails to convert?
johnw 2017-03-04 05:04:07
myEnum & id .~ 99999
bollu 2017-03-04 05:04:52
hm
bollu 2017-03-04 05:04:56
it errors out
bollu 2017-03-04 05:05:00
I think
johnw 2017-03-04 05:05:09
that's not a lawful lens, then
johnw 2017-03-04 05:05:13
it should at the very least be a prism
lpaste_ 2017-03-04 05:05:21
bollu pasted "euler-#4-fixed-syntax" at http://lpaste.net/353209
bollu 2017-03-04 05:05:34
berkobra: that is the fixed syntax, but you still have _semantic_ type errors :)
bollu 2017-03-04 05:05:46
berkobra: particularly, what is the type of isPalindrome?
bollu 2017-03-04 05:06:31
I see
bollu 2017-03-04 05:06:34
hm
bollu 2017-03-04 05:06:37
johnw: thanks
berkobra 2017-03-04 05:11:18
oh, do I need explicit type declaration for problem_4 ?
bollu 2017-03-04 05:17:27
it will warn you about conflicting choices of "which number type"
berkobra 2017-03-04 05:19:12
bollu what do you mean by fixed syntax
Squarism 2017-03-04 05:20:29
im trying to compile this but get 2 compile errors http://lpaste.net/353212
bollu 2017-03-04 05:20:43
berkobra: you don't need the "-"
Squarism 2017-03-04 05:20:45
...on line 96
bollu 2017-03-04 05:20:46
"="*
bollu 2017-03-04 05:20:58
berkobra: and you also need to push the "|" pattern guards a little ahead
berkobra 2017-03-04 05:21:23
do I have to double indent after 'where'?
berkobra 2017-03-04 05:21:27
or is it about the guards
berkobra 2017-03-04 05:21:55
I can't really wrap my head around the indentation rules of Haskell
sbrg 2017-03-04 05:22:21
berkobra: for the most part, things just need to be at the same indentation level to be a part of the same 'block'
sbrg 2017-03-04 05:22:51
I prefer to have 'where' on a line of its own, indented two spaces. definitions in the 'where' clause are indented 4 spaces
berkobra 2017-03-04 05:23:29
thanks sbrg
berkobra 2017-03-04 05:23:35
and bollu too
berkobra 2017-03-04 05:23:55
Now I can move on to the actual logic errors of the code :)
bollu 2017-03-04 05:26:07
every lens is Iso?
bollu 2017-03-04 05:26:13
sbrg: no worries :)
bollu 2017-03-04 05:26:21
johnw: every Lens is an Iso right?
bollu 2017-03-04 05:26:34
oh no
bollu 2017-03-04 05:26:37
every Iso is a Lens
bollu 2017-03-04 05:26:39
hmm
Squarism 2017-03-04 05:27:55
better paste with error : http://lpaste.net/353213
lyxia 2017-03-04 05:38:04
Squarism: createGameServerInstance must be polymorphic
lyxia 2017-03-04 05:38:21
but gameLauncher1 uses a monomorphic value
lyxia 2017-03-04 05:38:48
Squarism: did you mean to use an existential type?
Squarism 2017-03-04 05:39:02
lyxia, yep.. i want to use existential type
Squarism 2017-03-04 05:39:12
(never tried in haskell before)
lyxia 2017-03-04 05:39:46
Squarism: data GameLauncher = forall m1 m2 . GameLauncher { ... }
Squarism 2017-03-04 05:39:53
ah
Squarism 2017-03-04 05:40:23
that did the trick
Squarism 2017-03-04 05:40:28
thanks lyxia
lyxia 2017-03-04 05:40:33
yw
Nikola 2017-03-04 05:40:41
... so I want to write an application in haskell - the target platform is ghc on linux : After writing some data to disk, I would would sometimes like to call sync(2). How can I do that?
cocreature 2017-03-04 05:42:43
Nikola: it looks like the unix package provides fsync https://hackage.haskell.org/package/unix-2.7.2.1/docs/System-Posix-Unistd.html#v:fileSynchronise but not sync. so your only option is probably the C ffi
tsahyt 2017-03-04 05:44:19
what's the fastest pure haskell FFT implementation?
tsahyt 2017-03-04 05:44:43
probably equivalent to the fastest that does not bind to fftw
Nikola 2017-03-04 05:44:52
Aahhh ... thanks cocreature: How come a function like that is not in the standard library? Any OS would provide some way to synchronize buffers to disk, wouldn't if ?