-- it is stupid that we need UndecidableInstances just to call another
-- type function (see instance Apply below which requires this)
{-# LANGUAGE UndecidableInstances #-}
module Darcs.Patch.V2.Prim ( Prim(..) ) where

import Darcs.Prelude

import Data.Coerce (coerce )

import Darcs.Patch.Annotate ( Annotate )
import Darcs.Patch.Apply ( Apply(..) )
import Darcs.Patch.Commute ( Commute(..) )
import Darcs.Patch.FileHunk ( IsHunk )
import Darcs.Patch.Format
    ( PatchListFormat(..)
    , ListFormat(ListFormatV2)
    , FileNameFormat(FileNameFormatV2,FileNameFormatDisplay) )
import Darcs.Patch.Inspect ( PatchInspect )
import Darcs.Patch.Invert ( Invert )
import Darcs.Patch.Merge ( CleanMerge )
import Darcs.Patch.Read ( ReadPatch(..) )
import Darcs.Patch.Repair ( RepairToFL(..) )
import Darcs.Patch.Show
    ( ShowPatchBasic(..)
    , ShowPatchFor(..)
    , ShowPatch(..)
    , ShowContextPatch(..)
    )
import Darcs.Patch.Summary ( plainSummaryPrim, plainSummaryPrims )

import Darcs.Patch.Witnesses.Eq ( Eq2 )
import Darcs.Patch.Witnesses.Show ( Show1, Show2 )
import Darcs.Patch.Witnesses.Sealed ( mapSeal )

import Darcs.Patch.Prim.Class
    ( PrimConstruct(..), PrimCoalesce(..)
    , PrimDetails(..)
    , PrimShow(..), PrimRead(..)
    , PrimApply(..)
    , PrimSift(..)
    , PrimMangleUnravelled(..)
    )
import qualified Darcs.Patch.Prim.V1 as Base ( Prim )

newtype Prim x y = Prim { forall x y. Prim x y -> Prim x y
unPrim :: Base.Prim x y } deriving
    ( (forall wX wY. Prim wX wY -> AnnotatedM ()) -> Annotate Prim
forall wX wY. Prim wX wY -> AnnotatedM ()
forall (p :: * -> * -> *).
(forall wX wY. p wX wY -> AnnotatedM ()) -> Annotate p
$cannotate :: forall wX wY. Prim wX wY -> AnnotatedM ()
annotate :: forall wX wY. Prim wX wY -> AnnotatedM ()
Annotate
    , (forall (m :: * -> *) wX wY.
 ApplyMonad (ApplyState Prim) m =>
 Prim wX wY -> m ())
-> (forall (m :: * -> *) wX wY.
    ApplyMonad (ApplyState Prim) m =>
    Prim wX wY -> m ())
-> Apply Prim
forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
Prim wX wY -> m ()
forall (p :: * -> * -> *).
(forall (m :: * -> *) wX wY.
 ApplyMonad (ApplyState p) m =>
 p wX wY -> m ())
-> (forall (m :: * -> *) wX wY.
    ApplyMonad (ApplyState p) m =>
    p wX wY -> m ())
-> Apply p
$capply :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
Prim wX wY -> m ()
apply :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
Prim wX wY -> m ()
$cunapply :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
Prim wX wY -> m ()
unapply :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
Prim wX wY -> m ()
Apply
    , (forall wX wY.
 (:\/:) Prim Prim wX wY -> Maybe ((:/\:) Prim Prim wX wY))
-> CleanMerge Prim
forall wX wY.
(:\/:) Prim Prim wX wY -> Maybe ((:/\:) Prim Prim wX wY)
forall (p :: * -> * -> *).
(forall wX wY. (:\/:) p p wX wY -> Maybe ((:/\:) p p wX wY))
-> CleanMerge p
$ccleanMerge :: forall wX wY.
(:\/:) Prim Prim wX wY -> Maybe ((:/\:) Prim Prim wX wY)
cleanMerge :: forall wX wY.
(:\/:) Prim Prim wX wY -> Maybe ((:/\:) Prim Prim wX wY)
CleanMerge
    , (forall wX wY.
 (:>) Prim Prim wX wY -> Maybe ((:>) Prim Prim wX wY))
-> Commute Prim
forall wX wY. (:>) Prim Prim wX wY -> Maybe ((:>) Prim Prim wX wY)
forall (p :: * -> * -> *).
(forall wX wY. (:>) p p wX wY -> Maybe ((:>) p p wX wY))
-> Commute p
$ccommute :: forall wX wY. (:>) Prim Prim wX wY -> Maybe ((:>) Prim Prim wX wY)
commute :: forall wX wY. (:>) Prim Prim wX wY -> Maybe ((:>) Prim Prim wX wY)
Commute
    , (forall wX wY. Prim wX wY -> Prim wY wX) -> Invert Prim
forall wX wY. Prim wX wY -> Prim wY wX
forall (p :: * -> * -> *).
(forall wX wY. p wX wY -> p wY wX) -> Invert p
$cinvert :: forall wX wY. Prim wX wY -> Prim wY wX
invert :: forall wX wY. Prim wX wY -> Prim wY wX
Invert
    , (forall wX wY.
 Prim wX wY -> Maybe (FileHunk (ObjectIdOfPatch Prim) wX wY))
-> IsHunk Prim
forall wX wY.
Prim wX wY -> Maybe (FileHunk (ObjectIdOfPatch Prim) wX wY)
forall (p :: * -> * -> *).
(forall wX wY.
 p wX wY -> Maybe (FileHunk (ObjectIdOfPatch p) wX wY))
-> IsHunk p
$cisHunk :: forall wX wY.
Prim wX wY -> Maybe (FileHunk (ObjectIdOfPatch Prim) wX wY)
isHunk :: forall wX wY.
Prim wX wY -> Maybe (FileHunk (ObjectIdOfPatch Prim) wX wY)
IsHunk
    , (forall wA wB wC wD. Prim wA wB -> Prim wC wD -> Bool)
-> (forall wA wB wC. Prim wA wB -> Prim wA wC -> EqCheck wB wC)
-> (forall wA wC wB. Prim wA wC -> Prim wB wC -> EqCheck wA wB)
-> Eq2 Prim
forall wA wB wC. Prim wA wB -> Prim wA wC -> EqCheck wB wC
forall wA wC wB. Prim wA wC -> Prim wB wC -> EqCheck wA wB
forall wA wB wC wD. Prim wA wB -> Prim wC wD -> Bool
forall (p :: * -> * -> *).
(forall wA wB wC wD. p wA wB -> p wC wD -> Bool)
-> (forall wA wB wC. p wA wB -> p wA wC -> EqCheck wB wC)
-> (forall wA wC wB. p wA wC -> p wB wC -> EqCheck wA wB)
-> Eq2 p
$cunsafeCompare :: forall wA wB wC wD. Prim wA wB -> Prim wC wD -> Bool
unsafeCompare :: forall wA wB wC wD. Prim wA wB -> Prim wC wD -> Bool
$c=\/= :: forall wA wB wC. Prim wA wB -> Prim wA wC -> EqCheck wB wC
=\/= :: forall wA wB wC. Prim wA wB -> Prim wA wC -> EqCheck wB wC
$c=/\= :: forall wA wC wB. Prim wA wC -> Prim wB wC -> EqCheck wA wB
=/\= :: forall wA wC wB. Prim wA wC -> Prim wB wC -> EqCheck wA wB
Eq2
    , (forall wX wY. Prim wX wY -> [AnchoredPath])
-> (forall wX wY. (ByteString -> Bool) -> Prim wX wY -> Bool)
-> PatchInspect Prim
forall wX wY. Prim wX wY -> [AnchoredPath]
forall wX wY. (ByteString -> Bool) -> Prim wX wY -> Bool
forall (p :: * -> * -> *).
(forall wX wY. p wX wY -> [AnchoredPath])
-> (forall wX wY. (ByteString -> Bool) -> p wX wY -> Bool)
-> PatchInspect p
$clistTouchedFiles :: forall wX wY. Prim wX wY -> [AnchoredPath]
listTouchedFiles :: forall wX wY. Prim wX wY -> [AnchoredPath]
$chunkMatches :: forall wX wY. (ByteString -> Bool) -> Prim wX wY -> Bool
hunkMatches :: forall wX wY. (ByteString -> Bool) -> Prim wX wY -> Bool
PatchInspect
    , (forall (m :: * -> *) wX wY.
 ApplyMonad (ApplyState Prim) m =>
 FL Prim wX wY -> m ())
-> PrimApply Prim
forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
FL Prim wX wY -> m ()
forall (prim :: * -> * -> *).
(forall (m :: * -> *) wX wY.
 ApplyMonad (ApplyState prim) m =>
 FL prim wX wY -> m ())
-> PrimApply prim
$capplyPrimFL :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
FL Prim wX wY -> m ()
applyPrimFL :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
FL Prim wX wY -> m ()
PrimApply
    , Eq2 Prim
Invert Prim
Commute Prim
(Commute Prim, Eq2 Prim, Invert Prim) =>
(forall wX wY. FL Prim wX wY -> Maybe (FL Prim wX wY))
-> (forall wX wY. FL Prim wX wY -> FL Prim wX wY)
-> (forall wX wY wZ.
    Prim wX wY -> Prim wY wZ -> Maybe (Prim wX wZ))
-> (forall wX wY. Prim wX wY -> EqCheck wX wY)
-> (forall wA wB wC wD. Prim wA wB -> Prim wC wD -> Ordering)
-> PrimCoalesce Prim
forall wX wY. FL Prim wX wY -> Maybe (FL Prim wX wY)
forall wX wY. FL Prim wX wY -> FL Prim wX wY
forall wX wY. Prim wX wY -> EqCheck wX wY
forall wX wY wZ. Prim wX wY -> Prim wY wZ -> Maybe (Prim wX wZ)
forall wA wB wC wD. Prim wA wB -> Prim wC wD -> Ordering
forall (prim :: * -> * -> *).
(Commute prim, Eq2 prim, Invert prim) =>
(forall wX wY. FL prim wX wY -> Maybe (FL prim wX wY))
-> (forall wX wY. FL prim wX wY -> FL prim wX wY)
-> (forall wX wY wZ.
    prim wX wY -> prim wY wZ -> Maybe (prim wX wZ))
-> (forall wX wY. prim wX wY -> EqCheck wX wY)
-> (forall wA wB wC wD. prim wA wB -> prim wC wD -> Ordering)
-> PrimCoalesce prim
$ctryToShrink :: forall wX wY. FL Prim wX wY -> Maybe (FL Prim wX wY)
tryToShrink :: forall wX wY. FL Prim wX wY -> Maybe (FL Prim wX wY)
$csortCoalesceFL :: forall wX wY. FL Prim wX wY -> FL Prim wX wY
sortCoalesceFL :: forall wX wY. FL Prim wX wY -> FL Prim wX wY
$cprimCoalesce :: forall wX wY wZ. Prim wX wY -> Prim wY wZ -> Maybe (Prim wX wZ)
primCoalesce :: forall wX wY wZ. Prim wX wY -> Prim wY wZ -> Maybe (Prim wX wZ)
$cisIdentity :: forall wX wY. Prim wX wY -> EqCheck wX wY
isIdentity :: forall wX wY. Prim wX wY -> EqCheck wX wY
$ccomparePrim :: forall wA wB wC wD. Prim wA wB -> Prim wC wD -> Ordering
comparePrim :: forall wA wB wC wD. Prim wA wB -> Prim wC wD -> Ordering
PrimCoalesce
    , (forall wX wY. AnchoredPath -> Prim wX wY)
-> (forall wX wY. AnchoredPath -> Prim wX wY)
-> (forall wX wY. AnchoredPath -> Prim wX wY)
-> (forall wX wY. AnchoredPath -> Prim wX wY)
-> (forall wX wY. AnchoredPath -> AnchoredPath -> Prim wX wY)
-> (forall wX wY. String -> String -> String -> Prim wX wY)
-> (forall wX wY.
    AnchoredPath -> Int -> [ByteString] -> [ByteString] -> Prim wX wY)
-> (forall wX wY.
    AnchoredPath -> String -> String -> String -> Prim wX wY)
-> (forall wX wY.
    AnchoredPath -> ByteString -> ByteString -> Prim wX wY)
-> (forall wX wY.
    FileHunk (ObjectIdOfPatch Prim) wX wY -> Prim wX wY)
-> PrimConstruct Prim
forall wX wY. String -> String -> String -> Prim wX wY
forall wX wY. AnchoredPath -> Prim wX wY
forall wX wY.
AnchoredPath -> Int -> [ByteString] -> [ByteString] -> Prim wX wY
forall wX wY.
AnchoredPath -> String -> String -> String -> Prim wX wY
forall wX wY.
AnchoredPath -> ByteString -> ByteString -> Prim wX wY
forall wX wY. AnchoredPath -> AnchoredPath -> Prim wX wY
forall wX wY. FileHunk (ObjectIdOfPatch Prim) wX wY -> Prim wX wY
forall (prim :: * -> * -> *).
(forall wX wY. AnchoredPath -> prim wX wY)
-> (forall wX wY. AnchoredPath -> prim wX wY)
-> (forall wX wY. AnchoredPath -> prim wX wY)
-> (forall wX wY. AnchoredPath -> prim wX wY)
-> (forall wX wY. AnchoredPath -> AnchoredPath -> prim wX wY)
-> (forall wX wY. String -> String -> String -> prim wX wY)
-> (forall wX wY.
    AnchoredPath -> Int -> [ByteString] -> [ByteString] -> prim wX wY)
-> (forall wX wY.
    AnchoredPath -> String -> String -> String -> prim wX wY)
-> (forall wX wY.
    AnchoredPath -> ByteString -> ByteString -> prim wX wY)
-> (forall wX wY.
    FileHunk (ObjectIdOfPatch prim) wX wY -> prim wX wY)
-> PrimConstruct prim
$caddfile :: forall wX wY. AnchoredPath -> Prim wX wY
addfile :: forall wX wY. AnchoredPath -> Prim wX wY
$crmfile :: forall wX wY. AnchoredPath -> Prim wX wY
rmfile :: forall wX wY. AnchoredPath -> Prim wX wY
$cadddir :: forall wX wY. AnchoredPath -> Prim wX wY
adddir :: forall wX wY. AnchoredPath -> Prim wX wY
$crmdir :: forall wX wY. AnchoredPath -> Prim wX wY
rmdir :: forall wX wY. AnchoredPath -> Prim wX wY
$cmove :: forall wX wY. AnchoredPath -> AnchoredPath -> Prim wX wY
move :: forall wX wY. AnchoredPath -> AnchoredPath -> Prim wX wY
$cchangepref :: forall wX wY. String -> String -> String -> Prim wX wY
changepref :: forall wX wY. String -> String -> String -> Prim wX wY
$chunk :: forall wX wY.
AnchoredPath -> Int -> [ByteString] -> [ByteString] -> Prim wX wY
hunk :: forall wX wY.
AnchoredPath -> Int -> [ByteString] -> [ByteString] -> Prim wX wY
$ctokreplace :: forall wX wY.
AnchoredPath -> String -> String -> String -> Prim wX wY
tokreplace :: forall wX wY.
AnchoredPath -> String -> String -> String -> Prim wX wY
$cbinary :: forall wX wY.
AnchoredPath -> ByteString -> ByteString -> Prim wX wY
binary :: forall wX wY.
AnchoredPath -> ByteString -> ByteString -> Prim wX wY
$cprimFromHunk :: forall wX wY. FileHunk (ObjectIdOfPatch Prim) wX wY -> Prim wX wY
primFromHunk :: forall wX wY. FileHunk (ObjectIdOfPatch Prim) wX wY -> Prim wX wY
PrimConstruct
    , (forall wX wY. Prim wX wY -> [SummDetail]) -> PrimDetails Prim
forall wX wY. Prim wX wY -> [SummDetail]
forall (prim :: * -> * -> *).
(forall wX wY. prim wX wY -> [SummDetail]) -> PrimDetails prim
$csummarizePrim :: forall wX wY. Prim wX wY -> [SummDetail]
summarizePrim :: forall wX wY. Prim wX wY -> [SummDetail]
PrimDetails
    , (forall wX. Unravelled Prim wX -> Maybe (Mangled Prim wX))
-> PrimMangleUnravelled Prim
forall wX. Unravelled Prim wX -> Maybe (Mangled Prim wX)
forall (prim :: * -> * -> *).
(forall wX. Unravelled prim wX -> Maybe (Mangled prim wX))
-> PrimMangleUnravelled prim
$cmangleUnravelled :: forall wX. Unravelled Prim wX -> Maybe (Mangled Prim wX)
mangleUnravelled :: forall wX. Unravelled Prim wX -> Maybe (Mangled Prim wX)
PrimMangleUnravelled
    , (forall wX wY. Prim wX wY -> Bool) -> PrimSift Prim
forall wX wY. Prim wX wY -> Bool
forall (prim :: * -> * -> *).
(forall wX wY. prim wX wY -> Bool) -> PrimSift prim
$cprimIsSiftable :: forall wX wY. Prim wX wY -> Bool
primIsSiftable :: forall wX wY. Prim wX wY -> Bool
PrimSift
    , Int -> Prim x y -> ShowS
[Prim x y] -> ShowS
Prim x y -> String
(Int -> Prim x y -> ShowS)
-> (Prim x y -> String) -> ([Prim x y] -> ShowS) -> Show (Prim x y)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall x y. Int -> Prim x y -> ShowS
forall x y. [Prim x y] -> ShowS
forall x y. Prim x y -> String
$cshowsPrec :: forall x y. Int -> Prim x y -> ShowS
showsPrec :: Int -> Prim x y -> ShowS
$cshow :: forall x y. Prim x y -> String
show :: Prim x y -> String
$cshowList :: forall x y. [Prim x y] -> ShowS
showList :: [Prim x y] -> ShowS
Show
    )

instance Show1 (Prim wX)

instance Show2 Prim

instance ReadPatch Prim where
  readPatch' :: forall wX. Parser (Sealed (Prim wX))
readPatch' = (Sealed (Prim wX) -> Sealed (Prim wX))
-> Parser ByteString (Sealed (Prim wX))
-> Parser ByteString (Sealed (Prim wX))
forall a b. (a -> b) -> Parser ByteString a -> Parser ByteString b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((forall wX. Prim wX wX -> Prim wX wX)
-> Sealed (Prim wX) -> Sealed (Prim wX)
forall (a :: * -> *) (b :: * -> *).
(forall wX. a wX -> b wX) -> Sealed a -> Sealed b
mapSeal Prim wX wX -> Prim wX wX
forall wX. Prim wX wX -> Prim wX wX
forall x y. Prim x y -> Prim x y
Prim) (FileNameFormat -> Parser ByteString (Sealed (Prim wX))
forall wX. FileNameFormat -> Parser (Sealed (Prim wX))
forall (prim :: * -> * -> *) wX.
PrimRead prim =>
FileNameFormat -> Parser (Sealed (prim wX))
readPrim FileNameFormat
FileNameFormatV2)

fileNameFormat :: ShowPatchFor -> FileNameFormat
fileNameFormat :: ShowPatchFor -> FileNameFormat
fileNameFormat ShowPatchFor
ForDisplay = FileNameFormat
FileNameFormatDisplay
fileNameFormat ShowPatchFor
ForStorage = FileNameFormat
FileNameFormatV2

instance ShowPatchBasic Prim where
  showPatch :: forall wX wY. ShowPatchFor -> Prim wX wY -> Doc
showPatch ShowPatchFor
fmt = FileNameFormat -> Prim wX wY -> Doc
forall wA wB. FileNameFormat -> Prim wA wB -> Doc
forall (prim :: * -> * -> *) wA wB.
PrimShow prim =>
FileNameFormat -> prim wA wB -> Doc
showPrim (ShowPatchFor -> FileNameFormat
fileNameFormat ShowPatchFor
fmt) (Prim wX wY -> Doc)
-> (Prim wX wY -> Prim wX wY) -> Prim wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Prim wX wY -> Prim wX wY
forall x y. Prim x y -> Prim x y
unPrim

instance ShowContextPatch Prim where
  showPatchWithContextAndApply :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
ShowPatchFor -> Prim wX wY -> m Doc
showPatchWithContextAndApply ShowPatchFor
fmt = FileNameFormat -> Prim wX wY -> m Doc
forall (m :: * -> *) wA wB.
ApplyMonad (ApplyState Prim) m =>
FileNameFormat -> Prim wA wB -> m Doc
forall (prim :: * -> * -> *) (m :: * -> *) wA wB.
(PrimShow prim, ApplyMonad (ApplyState prim) m) =>
FileNameFormat -> prim wA wB -> m Doc
showPrimWithContextAndApply (ShowPatchFor -> FileNameFormat
fileNameFormat ShowPatchFor
fmt) (Prim wX wY -> m Doc)
-> (Prim wX wY -> Prim wX wY) -> Prim wX wY -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Prim wX wY -> Prim wX wY
forall x y. Prim x y -> Prim x y
unPrim

instance ShowPatch Prim where
  summary :: forall wX wY. Prim wX wY -> Doc
summary = Prim wX wY -> Doc
forall (prim :: * -> * -> *) wX wY.
PrimDetails prim =>
prim wX wY -> Doc
plainSummaryPrim (Prim wX wY -> Doc)
-> (Prim wX wY -> Prim wX wY) -> Prim wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Prim wX wY -> Prim wX wY
forall x y. Prim x y -> Prim x y
unPrim
  summaryFL :: forall wX wY. FL Prim wX wY -> Doc
summaryFL = Bool -> FL Prim wX wY -> Doc
forall (prim :: * -> * -> *) wX wY.
PrimDetails prim =>
Bool -> FL prim wX wY -> Doc
plainSummaryPrims Bool
False
  thing :: forall x y. Prim x y -> String
thing Prim wX wY
_ = String
"change"

-- This instance is here so that FL Prim and RL Prim also get
-- ShowPatch instances, see Darcs.Patch.Viewing
instance PatchListFormat Prim where
  -- In principle we could use ListFormatDefault when prim /= V1 Prim patches,
  -- as those are the only case where we need to support a legacy on-disk
  -- format. In practice we don't expect RepoPatchV2 to be used with any other
  -- argument anyway, so it doesn't matter.
  patchListFormat :: ListFormat Prim
patchListFormat = ListFormat Prim
forall (p :: * -> * -> *). ListFormat p
ListFormatV2

instance RepairToFL Prim where
  applyAndTryToFixFL :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
Prim wX wY -> m (Maybe (String, FL Prim wX wY))
applyAndTryToFixFL = (Maybe (String, FL Prim wX wY) -> Maybe (String, FL Prim wX wY))
-> m (Maybe (String, FL Prim wX wY))
-> m (Maybe (String, FL Prim wX wY))
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Maybe (String, FL Prim wX wY) -> Maybe (String, FL Prim wX wY)
forall a b. Coercible a b => a -> b
coerce (m (Maybe (String, FL Prim wX wY))
 -> m (Maybe (String, FL Prim wX wY)))
-> (Prim wX wY -> m (Maybe (String, FL Prim wX wY)))
-> Prim wX wY
-> m (Maybe (String, FL Prim wX wY))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Prim wX wY -> m (Maybe (String, FL Prim wX wY))
forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState Prim) m =>
Prim wX wY -> m (Maybe (String, FL Prim wX wY))
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(RepairToFL p, ApplyMonad (ApplyState p) m) =>
p wX wY -> m (Maybe (String, FL p wX wY))
applyAndTryToFixFL (Prim wX wY -> m (Maybe (String, FL Prim wX wY)))
-> (Prim wX wY -> Prim wX wY)
-> Prim wX wY
-> m (Maybe (String, FL Prim wX wY))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Prim wX wY -> Prim wX wY
forall x y. Prim x y -> Prim x y
unPrim