CurryInfo: stylechecker-2.0.0 / Check.AST.Indent.Deriving.checkDerivingC

definition:
checkDerivingC :: SpanInfo -> [ConstrDecl] -> [QualIdent]-> CSM ()
checkDerivingC si cons derivs@(deriv:_) = case si of
  (SpanInfo (Span (Position ls cs) (Position le ce)) ks) -> do
    let derivSpan = (ks !! ((length cons) + 1))
        firstKeySpan = (ks !! ((length cons) + 2))
    unless (ls == le) --one line
      (if ((getSpanCol (ks !! 1) == getSpanCol derivSpan) || (cs+2 == getSpanCol derivSpan)) -- alignment 'deriving'
        then
          (unless (le == getSpanLi derivSpan) --deriving one line
            (if (spanAlign (drop ((length cons) + 2) ks)) -- alignment symbols in deriving body
                then
                  (if (checkAlign getCol (getCol (getSpanInfo deriv)) derivs) -- aligment classes
                    then
                      -- indentation
                      (unless ((getSpanCol firstKeySpan == (getSpanCol derivSpan) + 2) || (getSpanLi firstKeySpan == getSpanLi derivSpan))
                                  (report (Message (Span (Position (getSpanLi derivSpan) (getSpanCol derivSpan)) (Position le ce))
                                            (colorizeKey "classes" <+> text "wrong indention")
                                            ( text "indent by 2 from"
                                            <+> colorizeKey "deriving"
                                            <+> text "write first class in same line as"
                                            <+> colorizeKey "deriving"
                                            )
                                    )
                            )
                      )
                    else
                      (report (Message (Span (Position (getSpanLi derivSpan) (getSpanCol derivSpan)) (Position le ce))
                                (colorizeKey "classes" <+> text "not aligned")
                                ( text "align derived"
                                <+> colorizeKey "classes"
                                )
                              )
                      )
                  )
                else
                  (report (Message (Span (Position (getSpanLi derivSpan) (getSpanCol derivSpan)) (Position le ce))
                            (colorizeKey "symbols" <+> text "in deriving body not aligned")
                            ( text "align"
                            <+> colorizeKey "("
                            <+> text ","
                            <+> colorizeKey ")"
                            <+> text "and"
                            <+> colorizeKey ","
                            )
                          )
                  )
            )
          )
        else
          (report (Message (Span (Position ls cs) (Position le ce))
                                  (colorizeKey "deriving" <+> text "wrong formatting")
                                  ( text "align"
                                  <+> colorizeKey "deriving"
                                  <+> text "with"
                                  <+> colorizeKey "="
                                  <+> text "or indent by 2 from"
                                  <+> colorizeKey "data"
                                  )
                  )
          )
      )
  _ -> return ()
checkDerivingC _ _ [] = return ()
demand:
argument 3
deterministic:
deterministic operation
documentation:
-- Checks formatting.
failfree:
<FAILING>
indeterministic:
referentially transparent operation
infix:
no fixity defined
iotype:
{({SpanInfo},_,{:}) |-> _ || ({NoSpanInfo},_,{:}) |-> _ || (_,_,{[]}) |-> _}
name:
checkDerivingC
precedence:
no precedence defined
result-values:
_
signature:
Curry.SpanInfo.SpanInfo -> [Curry.Types.ConstrDecl] -> [Curry.Ident.QualIdent]
-> Control.Monad.Trans.State.StateT Types.CheckState Data.Functor.Identity.Identity ()
solution-complete:
operation might suspend on free variables
terminating:
possibly non-terminating
totally-defined:
possibly non-reducible on same data term