Match pattern in function argument in haskell

There is a strange pattern matching in the code that defines the function (cradleRootDir -> projdir)

I assume this is intended to use the inline function and associates the result with the name projdir .

What is the name of this design?

 withGhcModEnv' :: (IOish m, GmOut m) => (FilePath -> (Cradle -> ma) -> ma) -> FilePath -> Options -> ((GhcModEnv, GhcModLog) -> ma) -> ma withGhcModEnv' withCradle dir opts f = withCradle dir $ \crdl -> withCradleRootDir crdl $ f (GhcModEnv opts crdl, undefined) where withCradleRootDir (cradleRootDir -> projdir) a = do cdir <- liftIO $ getCurrentDirectory eq <- liftIO $ pathsEqual projdir cdir if not eq then throw $ GMEWrongWorkingDirectory projdir cdir else a 

Constructor

 data Cradle = Cradle { cradleCurrentDir :: FilePath , cradleRootDir :: FilePath , cradleCabalFile :: Maybe FilePath , cradlePkgDbStack :: [GhcPkgDb] } deriving (Eq, Show) 
+7
haskell
source share
1 answer

Using View Patterns

Evaluation To compare the value of v with the pattern (expr → pat), evaluate (expr v) and compare the result with pat.

See the bondage file

 Default-Extensions: ScopedTypeVariables, RecordWildCards, NamedFieldPuns, ConstraintKinds, FlexibleContexts, DataKinds, KindSignatures, TypeOperators, ViewPatterns ^^^^^^^^^^^^ | | | | | 
+7
source share

All Articles