waddlaw / haskell-stack-trace-plugin

MIT License
18 stars 5 forks source link

Support the Handle pattern #8

Closed etorreborre closed 3 years ago

etorreborre commented 3 years ago

In our code base we have many components defined like this:

data Component m = Component {
  function1 :: Int -> Text -> m Text,
  function2 :: Text -> Int -> m Double
}

newComponent :: Monad m => Dependency m -> Component m
newComponent dependency = Component {..} where
  function1 :: Int -> Text -> m Text
  function1 n t = do
    r <- callDependency dependency t
    pure (show n <> "-" <> r)

  function2 :: Text -> Int -> m Double
  function2 = panic "todo"

Since the plugin only adds HasCallStack constraints to top level functions we don't get a stacktrace for function1 and function2. How hard would it be add?

waddlaw commented 3 years ago

@etorreborre I've implemented it, so can you please check if it works correctly in #11?

etorreborre commented 2 years ago

Hi @waddlaw sorry for being so slow to respond, I just didn't see your message and moved on :-(.

I just tried the plugin again and it is indeed working with where clauses, thanks! On the other hand I am getting many redundant constraints warnings even for simple functions like:

 • Redundant constraints: (HasCallStack, HasCallStack)
    • In the type signature for:
           contractConfig :: (HasCallStack, HasCallStack, HasCallStack) =>
                             ContractConfig
    |
225 | contractConfig :: ContractConfig
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Do you have any idea why those constraints would be duplicated?