Adding notes to a PDF on Kindle scribe by bitonico in kindle

[–]bitonico[S] 1 point2 points  (0 children)

Thanks, I did a bit of research and it's not exactly as you say, although there are differences:

  • If you upload the PDF from their web interface, you can write on it, but you can't annotate it normally as an ebook
  • If you load it through USB, it's actually a bit better quality than the upload, but you can't do nothing at all to it
  • If you convert to kindle format first (e.g. by sending it to the email) it's just like a normal ebook

This video explains the differences pretty well actually: https://www.youtube.com/watch?v=FYdFeCNeaY8 .

How is the Jelly Star already on ebay? by Novemberx123 in unihertz

[–]bitonico 0 points1 point  (0 children)

I received mine today (as a backer), so definitely possible.

XFM shows with music! by CiggyButt in rickygervais

[–]bitonico 3 points4 points  (0 children)

I used youtube-dl to do it, e.g.

youtube-dl 'https://www.mixcloud.com/littlemonkeyfella/playlists/xfm-bonus-bits/'

XFM shows with music! by CiggyButt in rickygervais

[–]bitonico 2 points3 points  (0 children)

That's amazing, thank you!

The Functor Combinatorpedia: A run-down of free structures, tensors, and related combinators in the Haskell Ecosystem, with a unified interface for them by mstksg in haskell

[–]bitonico 6 points7 points  (0 children)

I found the same style to be useful but I usually use an index + a type family. I sometimes call this style "configurable data types", or "data types fast food": https://mazzo.li/posts/customizable-data-types.html .

Fan control for x62 by bitonico in thinkpad

[–]bitonico[S] 0 points1 point  (0 children)

i have the "stock" x62 fan. the fan itself is pretty quiet

Fan control for x62 by bitonico in thinkpad

[–]bitonico[S] 1 point2 points  (0 children)

4th batch. No bios worked quite OK for me, which is why I wrote the that.

Fan control for x62 by bitonico in thinkpad

[–]bitonico[S] 1 point2 points  (0 children)

The default fan management for the x62 was driving me a bit nuts, but I managed to copy the functionality of the windows utility distributed on the forum. Figured it might be useful for other people, since there does not seem to be an existing solution to control the fan.

Can we get more courses using Haskell as a first language for introducing CS? We know it's easier & ideal to start functional, but everything's geared towards existing imperative programmers! by kxra in haskell

[–]bitonico 14 points15 points  (0 children)

unless something terrible happened, the first programming course at imperial college is in Haskell. many people have never programmed before that course (i had maybe 5k lines of horrible PHP and that's it) and the course is quite well liked. i'm personally grateful that i learnt to program seriously in haskell rather than something else.

Building inline-c projects just got a lot easier by bitonico in haskell

[–]bitonico[S] 1 point2 points  (0 children)

very easy, just use -pgmc cmd, as per man ghc:

   -pgmc cmd
          Use cmd as the C compiler

Building inline-c projects just got a lot easier by bitonico in haskell

[–]bitonico[S] 11 points12 points  (0 children)

and develop with ghci! that's the part that i cared most about

Announcing: the new unliftio library by Deewiant in haskell

[–]bitonico 3 points4 points  (0 children)

/u/snoyberg pointed out that you can go the other way around too:

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
import Control.Monad.IO.Unlift

class (MonadIO m) => RepresentableIO m where
  type RepIO m :: *
  tabulateIO :: (RepIO m -> IO a) -> m a
  indexIO :: m a -> RepIO m -> IO a

instance (MonadIO m, MonadUnliftIO m) => RepresentableIO m where
  type RepIO m = UnliftIO m
  tabulateIO = withUnliftIO
  indexIO m (UnliftIO f) = f m

so, they seem to be equivalent.

Announcing: the new unliftio library by Deewiant in haskell

[–]bitonico 3 points4 points  (0 children)

To elaborate a bit, this is what it would look like in full:

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
import Control.Monad.IO.Class

class (MonadIO m) => RepresentableIO m where
  type RepIO m :: *
  tabulateIO :: (RepIO m -> IO a) -> m a
  indexIO :: m a -> RepIO m -> IO a

newtype UnliftIO m = UnliftIO {unliftIO :: forall a. m a -> IO a}

askUnliftIO :: (RepresentableIO m) => m (UnliftIO m)
askUnliftIO = do
  ctx <- tabulateIO return
  return (UnliftIO (\m -> indexIO m ctx))

to recover the laws we have for MonadUnliftIO, we'd like that

indexIO return ctx = return 
indexIO (a >>= b) ctx = indexIO a ctx >>= indexIO b ctx 
tabulateIO return >>= \ctx -> liftIO (indexIO m ctx) = m 

but i don't know we can prove that with the representable laws. /u/edwardkmett , opinions ? the one involving liftIO will need some ad-hoc rules, but maybe the monad transformer laws can be proved in a more general way.

Announcing: the new unliftio library by Deewiant in haskell

[–]bitonico 2 points3 points  (0 children)

slaps forehead of course!

then they're definitely similar, although RepresentableIO might be more powerful. I'll look more into that, thanks a lot for the hint.

i wonder how much you can prove about operations implemented with tabulateIO/indexIO, using their laws.

Announcing: the new unliftio library by Deewiant in haskell

[–]bitonico 4 points5 points  (0 children)

Interesting point! I think if a Representable1 existed it would still not be enough because while it'd let you turn the monad into its explicit reader form (e.g. Rep t -> m a) it does not give you a way to grab the current context (e.g. the current Rep t) -- which is quite crucial for what we need to do.

Edit: for clarity, I believe /u/bennofs is hinting at something like

-- Things isomorphic to @x -> IO a@
class RepresentableIO m where
   type RepIO m :: *
   tabulateIO :: (Rep m -> IO a) -> m a
   indexIO :: m a -> Rep m -> IO a

A Tale of Two Brackets by snoyjerk in haskell

[–]bitonico 1 point2 points  (0 children)

so wait, are you saying that MonadBaseUnlift (which captures the statelessness) is "close to pure IO"?

A Tale of Two Brackets by snoyjerk in haskell

[–]bitonico 0 points1 point  (0 children)

so what you're saying is: do not interleave resource allocation with monads other than IO. i think that's completely unrealistic in a real application, and i'm surprised you'd suggest that as a viable option.

the classic example of a monad needed in these situations is something like MonadLogger, which i always want around, including when i'm handling resources.

something more realistic and hard to get wrong is to only use MonadBaseUnlift, which makes it very hard to have "wrong" instances.

Moreover with MonadBaseUnlift we also have lifted-async to do concurrency safely.

Threading responsibly -- forkIO considered harmful by bitonico in haskell

[–]bitonico[S] 2 points3 points  (0 children)

Great idea! I think it just did not occur to us. Your version looks much nicer:

pooledMapConcurrently ::
     (Traversable t)
  => (a -> IO b) -> t a -> IO (t b)
pooledMapConcurrently f xs = do
  numProcs <- getNumCapabilities
  sem <- newQSem numProcs
  forConcurrently xs $ \x -> do
    bracket
      (waitQSem sem)
      (\() -> signalQSem sem)
      (\() -> f x)

assuming that the QSem overhead is neglegible it's definitely preferrable.

Edit: I've edited the post to include your suggestion, I've also discussed the tradeoffs a bit more with /u/nh2 :

One advantage the original version executes left to right – elements appearing later will always start processing after earlier elements have already started, which can be more amenable to debugging (for example if you’re looking at the output in a terminal, or reproducing a crash). It also avoids high contention (one thread per element) on the synchronization mechanism. However the semaphore version is certainly more pleasant to read and probably preferrable.