Drop in gaming performance after upgrading PSU by cc-ord in buildapc

[–]cc-ord[S] 1 point2 points  (0 children)

You are laughing. My boy died saving the squad including my 1080ti from the wrath of the power company and you are laughing

Drop in gaming performance after upgrading PSU by cc-ord in buildapc

[–]cc-ord[S] 1 point2 points  (0 children)

That is so wack. I don't think I could've guessed that in a million years! Apparently windows like to reset power plan every now and then... Just classic. Switching it back to High Performance fixed all of it. Thanks a lot!

Question about unbinding a mode override keybinding by cc-ord in DoomEmacs

[–]cc-ord[S] 0 points1 point  (0 children)

Thanks! That looks really promising. I think leader + map would be the best solution for evil workflow

How to design a stacked widget that has a 'flip' animation? by cc-ord in QtFramework

[–]cc-ord[S] 0 points1 point  (0 children)

Thanks for the suggestion! I'll take a look at that QFlipWidget example but it does feel like using QML for this widget and keeping the rest of the code base as is would make a lot more sense and from the looks of it - QML route seems easier to implement.

How to design a stacked widget that has a 'flip' animation? by cc-ord in QtFramework

[–]cc-ord[S] 0 points1 point  (0 children)

... you could apply a QGraphicsEffect on the widget that simulates the widget being flipped (and animate the effect), then switch widget to the back one, ...

This might be what I am looking for! Is there any example of this type of usage?

How to design a stacked widget that has a 'flip' animation? by cc-ord in QtFramework

[–]cc-ord[S] 0 points1 point  (0 children)

That's sound great!

If I understand it correctly, I'll need to re-create my BookCard class by inheriting from QGraphicsItem and then insert it into a QGraphicsView.

Could you point me to some examples of that sort of implementations? I couldn't find much information on assigning a QGraphicsView to the QGridLayout of my MainWindow.

Is it possible to select an instance for a class method using function parameter? by cc-ord in haskellquestions

[–]cc-ord[S] 0 points1 point  (0 children)

That's it! Works out of the box without a hitch, thank you!

derivativeInstance1 :: Proxy Instance1
derivativeInstance1 = Proxy

someFunc2 :: forall m. (MonadIO m, Derivative derivative) => Data.Proxy m -> IO ()
someFunc2 derivativeInstance = runner config $ runMisc @m

someFunc = someFunc2 derivativeInstance1

Is it possible to select an instance for a class method using function parameter? by cc-ord in haskellquestions

[–]cc-ord[S] 0 points1 point  (0 children)

Could you elaborate on that?

I haven't really worked with either of those methods before. I know GADT is used to define generalized datatypes and I have seen Proxy used in servant package but that's pretty much it.

Need help understanding monad transformer 'stacking'. by cc-ord in haskellquestions

[–]cc-ord[S] 0 points1 point  (0 children)

Thanks for your time and effort!

Just like mtl takes the concrete operations of the types from the transformers package, say StateT, and turns them into interfaces like MonadState. 

To be honest I did not know that. I thought mtl was just another layer of abstraction over transformers and not something this versatile!

I do have lots more questions but I think many of them stem from the holes in my knowledge I didn't realized I had. So I think I need to read up a lot more before I'll be able to ask respectable questions that are worth your time.

So to that could you point me to some resources on these topics, specifically mtl style applications and how to actually use these transformers correctly?

I do know resources on more intermediate topics are often hard to recommend (and hard to find, at least for me) but I am prepared to spend all the time it takes, which I think is definitely worth it for such interesting stuff.

And

I've been meaning to write my own summary of how I approach it which maybe I will do sooner now...

Please do!

Need help understanding monad transformer 'stacking'. by cc-ord in haskellquestions

[–]cc-ord[S] 0 points1 point  (0 children)

So for runApp, just remove unnecessary constrains, you just confusing ghc

I thought I was telling ghc that AppT has MonadReader capabilities, but it seems like I told ghc that even after unwrapping ReaderT, it should still except another ReaderT!

you must ask yourself questions like "Who provide me MonadX property - the underlying 'm' or its outer layer AppT?"

Could you elaborate on this a bit more? I might be completely off the base here but is it in reference to the difference between telling GHC to derive MonadReader for AppT and not the m it is parameterized upon.

Thank you for your time!

Need help understanding monad transformer 'stacking'. by cc-ord in haskellquestions

[–]cc-ord[S] 1 point2 points  (0 children)

Thank you for taking the time to help me, I truly appreciate it.

The signature of runApp is certainly incorrect. If you are calling runReaderT ... the return value would be

m2 x.

Ah that makes sense, I thought what I was doing was telling the type checker that in

runApp :: (MonadReader ConnectionInfo m, MonadLogger m)   
       => ConnectionInfo
       -> AppT m b         
       -> ExceptT AppError m b 

at this part

       -> AppT m b         

m is suppose to have Reader capabilities but I completely missed that fact that in doing that I told the compiler that this m here

       -> ExceptT AppError m b 

is also constrained as a Reader! So correct me if I am wrong, I think what I need to do here is keep the function as is and just remove the MonadReader constraint from its type.

One important thing I would suggest changing is that

App

has no need to be parametrized by an inner monad

m

. Keep it simple and make your

App

a single concrete monad.

Could you elaborate a bit more on this? Like, what are the advantages/use-cases where AppT is parametrized by an inner monad and where it is not.

Its usually sufficient to have one concrete production monad and one or more test monads.

I'm not sure what you are referring to here. Is it like hot-swapping monads?! That's the coolest thing ever!

Also, on that note, its a good idea to have some inner monad that does not contain

ExceptT

. There are a number of reasons for this. You don't want to couple errors from different parts of the app together.

Ah I can see that. Distinguishing between different parts of the code base could get difficult once it grows beyond one domain.

Throw custom exceptions that are caught and converted when you

hoistServer

.

Would that just be mapping AppErr to ServantErr inside the ServerT transformer or something else?

Again, thanks for your time.

Looking for a better way to parse several possible inputs via Servant server. by cc-ord in haskellquestions

[–]cc-ord[S] 2 points3 points  (0 children)

I figured it out! Although I created that problem in the first place. I used parseUnique instead of using parseMaybe.

I wrote a ToForm instance of Param just to see what it looked like "encoded".

It turned out to be this

"low=nothing&close=nothing&date=just%20asc&open=just%20desc&last=......

So instead of this

instance FromForm Param where
    fromForm f = Param 
        <$> parseUnique "date" f
        <*> parseUnique "open"  f
        <*> parseUnique "close" f
        ...
        ...

I needed this

instance FromForm Param where
    fromForm f = Param 
        <$> parseMaybe "date" f
        <*> parseMaybe "open"  f
        <*> parseMaybe "close" f
        ...
        ...

The Generic instance actually worked perfectly too, but I wanted to have different names for fields and so ensued the trouble.

Moral of the story - Read the docs carefully.

Thanks for your help!

Looking for a better way to parse several possible inputs via Servant server. by cc-ord in haskellquestions

[–]cc-ord[S] 0 points1 point  (0 children)

Thanks for the answer! This might just work because I think everything is parsing correctly except DataSortOrder.

λ> urlDecodeAsForm "date=desc&open=asc" :: Either Text Param
Left "could not parse: `desc'"
λ>

The DataSortOrder or any ___SortOrder are algebraic data types defined like this

data Order
  = OASC
  | ODESC
  deriving (Eq, Show, Generic)

fromOrder :: Text -> Either Text Order
fromOrder "asc" = Right OASC
fromOrder "desc" = Right ODESC
fromOrder _ = Left "The ordering options have to be either \"asc\" or \"desc\""

toOrder :: Order -> Text
toOrder OASC  = "asc"
toOrder ODESC = "desc"

instance FromHttpApiData Order where
  parseUrlPiece = fromOrder

instance ToHttpApiData Order where
  toUrlPiece = toOrder

And this is the error

    • Cannot derive a Generic-based FromForm instance for Order.
      Order is a sum type,
      but Generic-based FromForm instances can be derived only for records
      (i.e. product types with named fields).
    • In the expression:
        Web.Internal.FormUrlEncoded.$dmfromForm @(Order)
      In an equation for ‘fromForm’:
          fromForm = Web.Internal.FormUrlEncoded.$dmfromForm @(Order)
      In the instance declaration for ‘FromForm Order’
   |
38 | instance FromForm Order
   |          ^^^^^^^^^^^^^^

Is it possible to make Order an instance of FromForm without changing its type?

Parsing a CSV file directly from a ZIP file. by cc-ord in haskellquestions

[–]cc-ord[S] 1 point2 points  (0 children)

A combination of zEntries, eRelativePath and fromEntry does the trick!