`Redundant <$>` should not trigger for lengthy `LambdaCase`
complyue opened this issue · 0 comments
complyue commented
Redundant <$>
should not trigger for lengthy LambdaCase
Map.lookup dbaPath <$> readIORef storeRef >>= \case
Nothing -> do
(hdr, da) <- mmapDBA @a (rootDir </> dbaPath) Nothing False
modifyIORef' storeRef $ Map.insert dbaPath (DbaData hdr da)
return (hdr, da)
Just (DbaData hdr da@(DeviceArray _cap _fp :: DeviceArray a')) -> case eqT of
Nothing ->
throwIO . userError $
"element type mismatch for dba in store: " ++ dbaPath
Just (Refl :: a :~: a') -> return (hdr, da)
Point-free style is less optimal for lengthy LambdaCase
blocks
Redundant <$>
Found:
Map.lookup dbaPath <$> readIORef storeRef
>>=
\case
Nothing
-> do (hdr, da) <- mmapDBA @a (rootDir </> dbaPath) Nothing False
modifyIORef' storeRef $ Map.insert dbaPath (DbaData hdr da)
return (hdr, da)
Just (DbaData hdr da@(DeviceArray _cap _fp :: DeviceArray a'))
-> case eqT of
Nothing
-> throwIO . userError
$ "element type mismatch for dba in store: " ++ dbaPath
Just (Refl :: a :~: a') -> return (hdr, da)
Why not:
readIORef storeRef
>>=
(\case
Nothing
-> do (hdr, da) <- mmapDBA @a (rootDir </> dbaPath) Nothing False
modifyIORef' storeRef $ Map.insert dbaPath (DbaData hdr da)
return (hdr, da)
Just (DbaData hdr da@(DeviceArray _cap _fp :: DeviceArray a'))
-> case eqT of
Nothing
-> throwIO . userError
$ "element type mismatch for dba in store: " ++ dbaPath
Just (Refl :: a :~: a') -> return (hdr, da))
. Map.lookup dbaPath
hlint(refact:Redundant <$>)