Search Haskell Channel Logs

Tuesday, February 21, 2017

#haskell channel featuring lyxia, xpika, kgadek, clmg,

xpika 2017-02-21 13:47:55
I basically want to: fmapPipe f p = p >-> (do { x <-await ; yield (f x)} )
xpika 2017-02-21 13:50:57
runEffect $ (fmap (Prelude.drop 1) stdinLn) >-> stdoutLn
xpika 2017-02-21 13:51:00
this doesn't work
lyxia 2017-02-21 13:52:26
http://hackage.haskell.org/package/pipes-extras-1.0.8/docs/Pipes-Extras.html arr?
lyxia 2017-02-21 13:53:16
oh it's called map in pipes
xpika 2017-02-21 13:55:11
lyxia: crosses fingers
xpika 2017-02-21 14:04:15
lyxia: not precisly what I wanted but pretty close
clmg 2017-02-21 14:13:06
Is there a simple way to provide a link to a parent in a tree-like structure of records?
clmg 2017-02-21 14:13:12
is this 'tying the knot'?
clmg 2017-02-21 14:14:30
If I put the parent as a field of the child record, it will just be a duplicate of the record, no?
kgadek 2017-02-21 14:15:50
clmg: no, it should work
kgadek 2017-02-21 14:16:01
(unless you make the field unpacked)
clmg 2017-02-21 14:16:42
kgadek: what if I do a `set` with lenses, will it set the value in both places?
kgadek 2017-02-21 14:25:53
clmg: as for lens question
kgadek 2017-02-21 14:25:59
no, it will not do that
kgadek 2017-02-21 14:26:18
let's use the example from my code
kgadek 2017-02-21 14:27:00
if you will change the root then… you don't actually make a change
kgadek 2017-02-21 14:27:07
you create a new `root`
kgadek 2017-02-21 14:27:13
the old one is still there
kgadek 2017-02-21 14:28:05
ok, so if you look at "pointers" you have essentially `root --> left --> root`
kgadek 2017-02-21 14:28:29
root has pointer to left children, which has pointer to its parent — that is, to the root
kgadek 2017-02-21 14:28:30
cool
kgadek 2017-02-21 14:28:38
and now you "modify" root
kgadek 2017-02-21 14:28:51
in Haskell you don't modify things, you create new ones
kgadek 2017-02-21 14:29:05
(unless you really insist ;) )
kgadek 2017-02-21 14:29:53
e.g. you say: take the `root`, modify its `left.val` to contain some new value
kgadek 2017-02-21 14:31:45
so new root2 and left2 objects are created
kgadek 2017-02-21 14:32:12
but wait
kgadek 2017-02-21 14:33:14
you didn't update left2 value for parent
kgadek 2017-02-21 14:33:14
so you have: root2 --> left2 --> root
kgadek 2017-02-21 14:33:14
actually, it's even deeper: root2 --> left2 --> root --> left
kgadek 2017-02-21 14:33:14
in other words: if you have knot tied, than any change will require WHOLE STRUCTURE to be recreated
kgadek 2017-02-21 14:34:24
this is… well, troublesome sometimes. If you have this situation, you'd usually use ST/IO monad to perform actual mutation (I told: you can insist! :) )
kgadek 2017-02-21 14:34:43
however, most often a zipper "idiom" is totally enough