e -> DerivDecl -> PE.PreExpr
caseExprFromDerivation v derDecl = PE.Case pattern cases
   where pattern = PE.Var v
         pfs = derDecl ^. derCases
         cases = L.map (PE.toExpr *** PE.toExpr . finalExpr) pfs
         finalExpr = fromRight . getEnd 
         fromRight = either (error "fromRight Left") id

caseExprFromDerivation :: Variable -> DerivDecl -> PE.PreExpr
caseExprFromDerivation v derDecl = PE.Case pattern cases
   where pattern = PE.Var v
         pfs = derDecl ^. derCases
         cases = L.map (PE.toExpr *** PE.toExpr . finalExpr) pfs
         finalExpr = fromRight . getEnd 
         fromRight = either (error "fromRight Left") id
caseExprFromDerivation v derDecl = PE.Case pattern cases
   where pattern = PE.Var v
         pfs = derDecl ^. derCases
         cases = L.map (PE.toExpr *** PE.toExpr . finalExpr) pfs
         finalExpr = fromRight . getEnd 
         fromRight = either (error "fromRight Left") id