edwardk 2017-02-25 08:49:12
something like: \x t -> standaloneDerivD [conT ''ForallXE `appT` x `appT` varT (mkName"a")] (appT x (appT t (varT (mkName "a")))
edwardk 2017-02-25 08:49:27
you can clean it up a little by let binding a = varT (mkName "a")
edwardk 2017-02-25 08:50:03
the key here is that the lowercased versions of the constructor names do everything in the monad
edwardk 2017-02-25 08:50:12
so you have some options
centril 2017-02-25 08:50:49
edwardk: right, so a == p in this case
edwardk 2017-02-25 08:51:16
\x t -> let a = VarT (mkName "a") in StandaloneDeriveD [ConT ''ForallXE `AppT` x `AppT` a] (AppT x (AppT t a))
edwardk 2017-02-25 08:51:24
that gives you a pure function that returns a 'Dec'
glguy 2017-02-25 08:51:46
becareful that you aren't using 'a' anywhere in the type you passed in
edwardk 2017-02-25 08:52:27
yeah, in the monad you can make sure that it generates a type variable 'with a name like a' that is distinct from any other
edwardk 2017-02-25 08:52:38
outside the monad like this you risk name capture
edwardk 2017-02-25 08:53:28
anyways with that you should be able to do something like $(foo <$> classes <*> types)
centril 2017-02-25 08:53:34
edwardk: not sure i follow - why would it capture a / p ?
centril 2017-02-25 08:53:55
since it is introduced in the deriving thingy
lpaste_ 2017-02-25 08:54:08
glguy pasted "for central" at http://lpaste.net/352973
edwardk 2017-02-25 08:54:10
consider if you passed in a type like (ConT ''Whatever `AppT` VarT (mkName "a")) as one of the types.
glguy 2017-02-25 08:54:25
autocorrect ate your name, centril
edwardk 2017-02-25 08:54:29
then you get a big statement where the same type variable name was used
edwardk 2017-02-25 08:54:53
i prefer glguy's version, less messy
centril 2017-02-25 08:55:19
glguy: nice, thanks =)
edwardk 2017-02-25 08:55:24
pure . VarT = varT?
glguy 2017-02-25 08:55:28
oops, pure . VarT
glguy 2017-02-25 08:55:32
yeah, already edited the paste
edwardk 2017-02-25 08:55:46
thats pretty much optimal then =)
centril 2017-02-25 09:01:18
glguy: hmm, where is ctx :: [TH.TypeQ] -> TH.CxtQ coming from ?
centril 2017-02-25 09:02:01
nvm =)
glguy 2017-02-25 09:04:05
edwardk: I started factoring out the logic for normalizing reified DataD/NewtypeDs which can deal with the new gadt syntax stuff from GHC 8 and then basing lens code on that https://github.com/glguy/lens-th/blob/master/src/Test.hs
edwardk 2017-02-25 09:04:38
nice
glguy 2017-02-25 09:04:46
I needed the normalizing pass that existing lens does part of in other code
glguy 2017-02-25 09:07:07
Gives a nicer view of constructors https://github.com/glguy/th-abstraction/blob/master/src/Language/Haskell/TH/Datatype.hs#L58-L65 than Con
johnw 2017-02-25 09:12:57
cocreature: ping
centril 2017-02-25 09:12:58
edwardk, glguy: got problems with GHC stage restrictions... should I take ForallXE as a parameter to fix this?
cocreature 2017-02-25 09:13:58
johnw: pong
mangobot 2017-02-25 09:22:00
if there is one card Card and list of cards [Cards], data Card = Card Color Num, how can i use the filter function to filter the list for only the cards that have the same Num as this card in the argument? http://lpaste.net/352970
mangobot 2017-02-25 09:22:17
cant get the syntax correctly
mangobot 2017-02-25 09:24:18
\(c n) -> n == ...? how to i acces the second elem in every tupels from the [Cards] list
Akii 2017-02-25 09:24:18
on it
Akii 2017-02-25 09:24:26
http://lpaste.net/352970
Akii 2017-02-25 09:24:28
that might work
Akii 2017-02-25 09:24:46
might require lambda case lang extension
edwardk 2017-02-25 09:26:14
centril: how so?
mangobot 2017-02-25 09:26:20
Akii thanks! will check now
edwardk 2017-02-25 09:26:37
so long as the sections read top to bottom through the file you should be okay
edwardk 2017-02-25 09:26:54
that everything you need to be in scope in the slice is defined above the slice
edwardk 2017-02-25 09:27:00
er splice
Akii 2017-02-25 09:28:14
whats this function called that interleaves lists?
centril 2017-02-25 09:28:25
edwardk: moved it to a new file instead, which works too :)
edwardk 2017-02-25 09:28:44
k
hexagoxel 2017-02-25 09:28:54
Akii: intersperse/intercalate (?)
Akii 2017-02-25 09:29:32
:o
Akii 2017-02-25 09:29:55
I thought there was a function that would [a] -> [a] -> [a]
Akii 2017-02-25 09:31:30
take one from the first, then the second, then the first again
hexagoxel 2017-02-25 09:35:02
join . transpose?
hexagoxel 2017-02-25 09:35:45
Akii: ^
monochrom 2017-02-25 09:36:13
@type join . transpose
lambdabot 2017-02-25 09:36:13
[[a]] -> [a]
hexagoxel 2017-02-25 09:36:13
> join . transpose $ [[1,2,3], [4,5,6]]
lambdabot 2017-02-25 09:36:13
[1,4,2,5,3,6]
Akii 2017-02-25 09:37:33
I should take a look at list comprehensions http://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.OldList.html#transpose
tfc[m] 2017-02-25 09:39:20
if i have a "Just (Just 1, Just 2)", but i want Just (1,2) from this, or Nothing if anything is nothing related in there, how do i do this?
hpc 2017-02-25 09:42:26
:t join . fmap uncurry
lambdabot 2017-02-25 09:42:28
((a1, b) -> a1 -> b -> a) -> (a1, b) -> a
hpc 2017-02-25 09:42:33
well that's not remotely it
kadoban 2017-02-25 09:42:48
tfc[m]: An explicit case sounds like the easiest way to me.
hpc 2017-02-25 09:42:53
yeah
hpc 2017-02-25 09:43:06
once you get it to Just (Just (1, 2)), you can use join as well
hexagoxel 2017-02-25 09:43:15
:t (>>= uncurry (liftA2 (,)))
lambdabot 2017-02-25 09:43:17
Monad m => m (m a, m b) -> m (a, b)
hpc 2017-02-25 09:43:30
:t \(x, y) -> do {a <- x; b <- y; return (a, b)}
kadoban 2017-02-25 09:43:31
Nice
lambdabot 2017-02-25 09:43:33
Monad m => (m t, m t1) -> m (t, t1)
hexagoxel 2017-02-25 09:43:59
explicit case probably still is better :)
hpc 2017-02-25 09:44:00
don't try and golf it like we just did though
Tuplanolla 2017-02-25 09:44:17
No! Lenses!
tfc[m] 2017-02-25 09:44:18
lol so many ways. :D
kadoban 2017-02-25 09:44:23
Probably, but it's still cool.
Tuplanolla 2017-02-25 09:44:28
> preview (_Just . both . _Just) (Just (Just 1, Just 2)) :: Maybe Int
lambdabot 2017-02-25 09:44:33
Just 1
tfc[m] 2017-02-25 09:44:37
ok whats the lens way?
hpc 2017-02-25 09:44:39
we have to write it on one line because it's irc, but use the abstractions we do to write it more nicely