From 9dc3b9f07186d612e994447dc050613af4b4c1aa Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Sat, 8 Jun 2024 23:26:03 +0200 Subject: [PATCH] Actually fixed simplifier ticks exhausted by avoding redundancy At ZuriHac ben explained me how this could have been caused by the case analysis. Turns out the we three redundant recursion steps (3 different case branches to `fill`). By removing the redundant code and reducing this to only one branch, the case analysis will not hit the limit anymore. The INLINEABLE fix previously likely just stopped GHC from inlining it altogether. --- IHP/Controller/Param.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/IHP/Controller/Param.hs b/IHP/Controller/Param.hs index 43a72229e..382d6714e 100644 --- a/IHP/Controller/Param.hs +++ b/IHP/Controller/Param.hs @@ -622,13 +622,16 @@ instance (FillParams rest record , HasField "meta" record ModelSupport.MetaBag , SetField "meta" record ModelSupport.MetaBag ) => FillParams (fieldName:rest) record where - fill !record = do - let name :: ByteString = cs $! (symbolVal (Proxy @fieldName)) - case paramOrError name of - Right !(value :: fieldType) -> fill @rest (setField @fieldName value record) - Left ParamCouldNotBeParsedException { parserError } -> fill @rest (attachFailure (Proxy @fieldName) (cs parserError) record) - Left ParamNotFoundException {} -> fill @rest record - {-# INLINABLE fill #-} + fill !record = + let + name :: ByteString = cs $! (symbolVal (Proxy @fieldName)) + record' = case paramOrError name of + Right !(value :: fieldType) -> setField @fieldName value record + Left ParamCouldNotBeParsedException { parserError } -> attachFailure (Proxy @fieldName) (cs parserError) record + Left ParamNotFoundException {} -> record + in + fill @rest record' + {-# INLINE fill #-} ifValid :: (HasField "meta" model ModelSupport.MetaBag) => (Either model model -> IO r) -> model -> IO r ifValid branch model = branch $! if ModelSupport.isValid model