mniip 2017-02-06 19:48:32
oh wow
mniip 2017-02-06 19:49:00
Nat(f, g) = forall c. Hom(f c, g c)
mniip 2017-02-06 19:49:10
apparently that's a lemma
mniip 2017-02-06 19:49:16
and I've always taken it for granted
Xnuk 2017-02-06 20:01:57
Is there any JSON5 parser?
Lokathor 2017-02-06 20:03:21
"Be aware that the Functor, Traversable and Data instances are the same as for the Data.Map.Lazy module, so if they are used on strict maps, the resulting maps will be lazy."
opqdonut 2017-02-06 20:03:22
oh, that sounds nice
Lokathor 2017-02-06 20:03:26
what a sad sentence to find in the docs
opqdonut 2017-02-06 20:03:29
json5 I mean
Xnuk 2017-02-06 20:04:54
I need "unquoted object key" feature, but seems Haskell doesn't have package which supports this.
Xnuk 2017-02-06 20:06:03
If no package exists, I need to play with JS AST once again...
slack1256 2017-02-06 20:06:09
mniip: is that a lemma? doesn't it follow from the definition of naturality?
slack1256 2017-02-06 20:06:30
Mmmm => is trivial, maybe <= is the one more involved
quchen 2017-02-06 20:06:52
There is no strict Map type, there is only an alternative API that forces all values going into a lazy Map.
mniip 2017-02-06 20:06:56
slack1256, I'm denoting a end by forall
mniip 2017-02-06 20:07:04
like, a categorical end
quchen 2017-02-06 20:07:18
This is great for compatibility and dropping in the lazy/strict variant.
quchen 2017-02-06 20:07:30
This is not great if you expect a strict Map type.
Lokathor 2017-02-06 20:07:48
quchen, :S
quchen 2017-02-06 20:08:01
Note that Map is strict in the keys already. Just not necessarily in the values.
Lokathor 2017-02-06 20:08:19
oh well, in my current case it doesn't matter
slack1256 2017-02-06 20:08:48
TIL: about end functors
mniip 2017-02-06 20:09:57
slack1256, even then
mniip 2017-02-06 20:10:01
it's nontrivial
mniip 2017-02-06 20:10:21
naturality guarantees that, precisely, f . eta_X = eta Y . fmap f
Lokathor 2017-02-06 20:10:48
oh cripe
mniip 2017-02-06 20:10:48
it doesn't require eta to be continuous
Lokathor 2017-02-06 20:11:02
stackage, even nightly stackage, is several versions behind on Containers
Alxandr 2017-02-06 20:27:07
Hi. I have a (a -> IO b) and a (b -> c) function, and need to combine them into (a -> IO c), what's the best way to do that?
erisco 2017-02-06 20:27:23
(fmap . fmap)
mniip 2017-02-06 20:27:51
fmap f . g
jchia 2017-02-06 20:28:09
How can i 'lift' System.IO.withFile so that the signature is changed to have MonadIO instead of IO? Or, is there an alternative function I can use with MonadIO accomplishing the same effect?
Alxandr 2017-02-06 20:28:24
Isn't that the same as <$>
magthe 2017-02-06 20:28:35
Alxandr: yupp
magthe 2017-02-06 20:28:37
it is
mniip 2017-02-06 20:28:37
it is, but fmap is partially applied here
liste 2017-02-06 20:28:38
:t liftIO -- jchia
lambdabot 2017-02-06 20:28:40
MonadIO m => IO a -> m a
erisco 2017-02-06 20:28:47
you need two <$>'s
Alxandr 2017-02-06 20:28:49
I'll try
jchia 2017-02-06 20:28:55
liste: I can't just liste the withFile, can I?
jchia 2017-02-06 20:29:12
liste: s/liste/liftIO/
mniip 2017-02-06 20:29:19
jchia, I don't think the abstraction of withFile is going to work with an arbitrary MonadIO
jchia 2017-02-06 20:30:07
mniip: Can't I transform withFile into a MonadIO m => FilePath -> IOMode (Handle -> m r) -> m r ?
Lokathor 2017-02-06 20:30:36
YEAH
Lokathor 2017-02-06 20:30:47
guys i got the start of a text adventure going
Alxandr 2017-02-06 20:30:48
Wey, that worked :)
Lokathor 2017-02-06 20:31:03
and it only uses three threads :P
Alxandr 2017-02-06 20:31:04
I've been trying just about any combination of <$> and >=> :P
mniip 2017-02-06 20:31:05
jchia, you can, but the function that is being with'd can break the abstraction
mniip 2017-02-06 20:31:18
if m, for example, includes ListT
mniip 2017-02-06 20:31:31
you can end up closing the handle on the first result
mniip 2017-02-06 20:31:39
and then the second result will work with an invalid handle
mniip 2017-02-06 20:32:11
and
mniip 2017-02-06 20:32:25
I don't know if there's a monad-generic way to close the handle upon exit from the function
tfc 2017-02-06 20:32:38
Lokathor: is its source code online anywhere?
Lokathor 2017-02-06 20:32:45
tfc one moment
mniip 2017-02-06 20:32:45
EitherT e IO is going to skip the close if the inner function throws
Alxandr 2017-02-06 20:32:46
<* closeHandle?
Lokathor 2017-02-06 20:33:55
tfc https://github.com/Lokathor/galaxy-break sadly it's windows only at the moment
tfc 2017-02-06 20:34:15
Lokathor: what are the dependencies that make it windows only?
Lokathor 2017-02-06 20:34:16
because i haven't fixed the linux "front end" since I changed how the dirver works
mniip 2017-02-06 20:34:24
the second you say 'liftIO x' you sign up for not knowing where and when your IO actin gets executed
jchia 2017-02-06 20:34:25
mniip: Concretely, I have a [ReaderT r IO ()] that I'm trying to download and write multiple files, using the same environment. Any suggestions what I can use instead of withFile?
mniip 2017-02-06 20:34:41
jchia, well in that case withFile will work
Lokathor 2017-02-06 20:35:18
tfc, right now the windows version polls very rapidly for inputs as it reads in data, and the linux version is just not that fancy, so... well it might kinda work if i fiddle with it a bit
tfc 2017-02-06 20:35:30
Lokathor: i see
tfc 2017-02-06 20:35:38
Lokathor: don't have any windows here.
Lokathor 2017-02-06 20:35:51
tfc, well the game is not exciting anyway at the moment
Lokathor 2017-02-06 20:35:55
but you can check the code
Lokathor 2017-02-06 20:36:05
i'll see if i can fix the linux version
tfc 2017-02-06 20:36:35
Lokathor: hehe, no problem, i do not have any exaggerated expectations. it's just that i am learning haskell at the time and it often helps to read foreign code (if it's not too complex yet)
mniip 2017-02-06 20:36:36
:t \path mode f -> do x <- ask; System.IO.withFile path mode (runReaderT x)
lambdabot 2017-02-06 20:36:38
MonadReader (ReaderT GHC.IO.Handle.Types.Handle IO b) IO => FilePath -> GHC.IO.IOMode.IOMode -> t -> IO b
mniip 2017-02-06 20:36:52
:t \path mode f -> do x <- ask; System.IO.withFile path mode (runReaderT f x)
lambdabot 2017-02-06 20:36:54
MonadReader r IO => FilePath -> GHC.IO.IOMode.IOMode -> ReaderT r ((->) GHC.IO.Handle.Types.Handle) (IO b) -> IO b
mniip 2017-02-06 20:37:05
bleh
mniip 2017-02-06 20:37:15
:t \path mode f -> do x <- ask; System.IO.withFile path mode (\handle runReaderT (f handle) x)
lambdabot 2017-02-06 20:37:17
error: Parse error in pattern: f
mniip 2017-02-06 20:37:24
:t \path mode f -> do x <- ask; System.IO.withFile path mode (\handle -> runReaderT (f handle) x)
lambdabot 2017-02-06 20:37:25
MonadReader r IO => FilePath -> GHC.IO.IOMode.IOMode -> (GHC.IO.Handle.Types.Handle -> ReaderT r IO b) -> IO b
mniip 2017-02-06 20:37:28
there we go
mniip 2017-02-06 20:37:45
hm
Lokathor 2017-02-06 20:37:48
tfc, well the reason that the linux version is messed is that i intend for it to be very concurrent later on... but at the moment
mniip 2017-02-06 20:37:51
needs more liftIO but you get the idea
Alxandr 2017-02-06 20:40:25
How about this then: I have (getArgs :: IO [String]), (f :: [String] -> a) and (toJSONFilter :: a -> ByteString -> IO ByteString) and I need a (ByteString -> IO ByteString)
Lokathor 2017-02-06 20:40:38
tfc, okay try pulling the repo and building now
tfc 2017-02-06 20:40:54
lokathor one moment
Lokathor 2017-02-06 20:40:56
i think it'll work on linux/mac, but just kinda less good than i'd want in a final product
tfc 2017-02-06 20:41:01
Lokathor: will report back in 10 minutes
Lokathor 2017-02-06 20:41:07
cool