ph88 2017-03-05 06:45:31
i don't have any better ideas
johnw 2017-03-05 06:46:22
I don't understand why these two steps need to be separated
johnw 2017-03-05 06:46:34
I feel like I don't have the full picture
ph88 2017-03-05 06:46:54
what else can i tell you ?
lpaste_ 2017-03-05 06:50:30
glguy pasted "starting point for ph88" at http://lpaste.net/353242
ph88 2017-03-05 06:50:48
nice module name
glguy 2017-03-05 06:50:49
You can use that same class to update by value or index
ph88 2017-03-05 06:51:03
oh lens ^^
johnw 2017-03-05 06:51:30
glguy is also allowing a arbitrary tree structure,
johnw 2017-03-05 06:51:42
so (((1, 3), 2), 0) would be allowed too
ph88 2017-03-05 06:52:15
ye
ph88 2017-03-05 06:52:24
but what about changing the value of the highest to 10 ?
glguy 2017-03-05 06:53:26
*Ph88> itoListOf (indexing ints) (1::Int,(3::Int,(2::Int,0::Int)))
glguy 2017-03-05 06:53:26
[(0,1),(1,3),(2,2),(3,0)]
glguy 2017-03-05 06:54:02
*Ph88> set (elementOf (indexing ints) 2) 20 (1::Int,(3::Int,(2::Int,0::Int)))
glguy 2017-03-05 06:54:02
(1,(3,(20,0)))
glguy 2017-03-05 06:54:09
You can build stuff like that
ph88 2017-03-05 06:54:25
set, is that lens ?
glguy 2017-03-05 06:54:29
yeah
ph88 2017-03-05 06:54:52
maybe best to do it without lens ?
glguy 2017-03-05 06:55:02
It's not really worth doing in general
glguy 2017-03-05 06:55:12
but if you're going to do it, let's not make it harder than we need to :)
ph88 2017-03-05 06:55:31
what do you mean it's not worth doing ?
glguy 2017-03-05 06:57:22
Working with trees of tuples instead of a more appropriate type for the operations at hand?
monochrom 2017-03-05 06:58:32
I think dependent type fans would be thrilled. A tree type that tells you the value's tree shape, like a vector type that tells you the value's length (which is vector shape).
ph88 2017-03-05 06:58:36
ooh that
ph88 2017-03-05 07:03:33
glguy, why did you made a typeclass for it ?
ph88 2017-03-05 07:03:51
oh i think i know why actually ^^
ph88 2017-03-05 07:14:37
does someone know a function like Control.Lens.Fold.findOf that returns the rightmost element that matches the predicate ?
zennist 2017-03-05 07:19:11
i finally figured out why ghc is using ghci on compile phase when i'm not using template haskell - i have some ANN annotations....
Gurkenglas 2017-03-05 07:19:24
ph88, lastOf combined with filtered?
ph88 2017-03-05 07:20:13
i'll try it Gurkenglas
ertes 2017-03-05 07:22:44
is there a way with 'zoom' to access the current index of an indexed traversal?
ph88 2017-03-05 07:26:13
Gurkenglas, can i use filtered as is or do i need to combine it with a function to do the traversal ?
Gurkenglas 2017-03-05 07:26:25
:t filtered
lambdabot 2017-03-05 07:26:27
(Choice p, Applicative f) => (a -> Bool) -> Optic' p f a a
ph88 2017-03-05 07:26:48
hmz
Gurkenglas 2017-03-05 07:27:52
That specializes to (a -> Bool) -> Fold' a a.
ph88 2017-03-05 07:29:16
i don't know where to call that function
ph88 2017-03-05 07:29:30
i have now lastOf ints (1::Int,(3::Int,(2::Int,0::Int))) Just 0
ph88 2017-03-05 07:29:40
this seems to work
ph88 2017-03-05 07:30:31
but lastOf does not take an argument that matches the type of filtered
glguy 2017-03-05 07:30:31
lastOf (ints . filtered odd)
glguy 2017-03-05 07:33:46
filtered (==3) is only 3
glguy 2017-03-05 07:34:15
err, no, I think I'm wrong there
glguy 2017-03-05 07:35:34
It's similar: *Ph88> lengthOf (ints . only 3) (1::Int,(3::Int,(2::Int,0::Int)))
glguy 2017-03-05 07:35:34
1
ph88 2017-03-05 07:35:49
how can i not just get the last element but get the entire structure back with the last element that matches the predicate ?
saurabhnanda 2017-03-05 07:35:55
Is it possible to have a "functional dependency" of sorts between type-variables in a function signature, eg runQuery :: (haskells -> columns) => Connection -> Query columns -> IO [haskells]
ph88 2017-03-05 07:36:27
i mean i want to modify the last element that matches the predicate, but get the entire structure back with that one element modified
ertes 2017-03-05 07:41:15
saurabhnanda: how would that be resolved?
ertes 2017-03-05 07:41:43
saurabhnanda: you could use a type family, of course
saurabhnanda 2017-03-05 07:42:07
ertes: I'm not actually sure. I'm trying to say if `haskells` is inferred by the compiler (based on usage), then there should be only one type of `columns` that the compiler can infer.
bollu 2017-03-05 07:42:23
saurabhnanda: can you not use an actual functional dependency?
ertes 2017-03-05 07:42:29
saurabhnanda: the compiler still needs to actually infer it
saurabhnanda 2017-03-05 07:42:32
ertes: and btw, haskells & columns can very well be record types.
ertes 2017-03-05 07:42:50
saurabhnanda: so you need an explicit function, e.g. a type family
saurabhnanda 2017-03-05 07:42:59
bollu: functional dependencies are only on type-classes, right?
lyxia 2017-03-05 07:43:23
saurabhnanda: you can define a type synonym
ertes 2017-03-05 07:43:25
type family Columns haskells
lyxia 2017-03-05 07:43:33
that ^
glguy 2017-03-05 07:43:36
ph88: You can use 'holesOf' to get a view of an element in the structure and a way to put it back
Athas 2017-03-05 07:43:59
Grrr, I disagree with hlint that '&&' is better than 'and'.
ertes 2017-03-05 07:44:01
runQuery :: Connection -> Query (Columns haskells) -> IO [haskells]
saurabhnanda 2017-03-05 07:44:06
is the other way around easier? columns -> haskells?
ertes 2017-03-05 07:44:07
saurabhnanda: like that
Athas 2017-03-05 07:44:10
Whatever. The computer gets its way!
bollu 2017-03-05 07:44:14
ertes: can you force a type family to be injective?
ertes 2017-03-05 07:44:55
bollu: yes, since… uh… was it 7.10 or 8.0?
ertes 2017-03-05 07:45:06
in any case you can use -XTypeFamilyDependencies