SlideShare una empresa de Scribd logo
1 de 58
Descargar para leer sin conexión
Recursion Pattern Analysis and Feedback




                   Recursion Pattern Analysis and Feedback

                                  Sander Mak              Thomas van Noort

                            Center for Software Technology, Universiteit Utrecht


                                              October 27, 2006




                                  Center for Software Technology                   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback


  Overview

         Introduction
    1


         Recognizing Patterns
    2


         Feedback
    3


         Other applications
    4


         Implementation
    5


         Related Work
    6


         Conclusion
    7




                                  Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Introduction


  Why focus on recursion?
    Recursion is an essential part of Haskell:

                                it is the only way to loop or iterate

    spacer




                                  Center for Software Technology        Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Introduction


  Why focus on recursion?
    Recursion is an essential part of Haskell:

                                it is the only way to loop or iterate

    spacer
    Sometimes this message is taken to heart. Or too hard...
    Naive recursion
    f[]        =1
    f (x : xs) = (x + 1) ∗ f xs




                                  Center for Software Technology        Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Introduction


  Why focus on recursion?
    Recursion is an essential part of Haskell:

                                it is the only way to loop or iterate

    spacer
    Sometimes this message is taken to heart. Or too hard...
    Naive recursion
    f[]        =1
    f (x : xs) = (x + 1) ∗ f xs

    Pretty recursion
    f = foldr (∗) 1 . map (+1)
    or :
    f = foldr (λ x xs → (x + 1) ∗ xs) 1

                                  Center for Software Technology        Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Introduction


  Our goal

    Eliminate Haskell-recursion illiteracy:
    IRC transcript
      <CosmicRay>                  so let’s say I’m writing a recursive function like this:
      <CosmicRay>                  myFoo [] = []
      <CosmicRay>                  myFoo (x:xs) = (x + 5) : myFoo xs
      <JaffaCake>                   i.e. map (+5)
      <CosmicRay>                  right, but I don’t know how map works internally,
                                   so I wrote it out
      <JaffaCake>                   it works just like that ;)

    spacer
    (and improve life for Bastiaan by doing so)


                                  Center for Software Technology          Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Introduction


  Research questions


    Improvement of recursive definitions is quite a broad goal. More
    concrete sub-questions are:
        Which recursion combinators are available?
                   Usual suspects: foldr , map
                   But also: filter , foldl, etc.
           Which patterns do we want to recognize?
                   Are some functions better of in a naive definition?
                   Where are recursion patterns described?
           How do we present these improvements?
           Where do we present these improvements?




                                  Center for Software Technology        Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Recognizing Patterns


 What constitutes a pattern?
    No formal definition (yet), but there are several different sides: spacer
    Syntactic pattern:

               :: [Int] → Int
    f
    f[]        =0
    f (x : xs) = x + f xs




                                  Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Recognizing Patterns


 What constitutes a pattern?
    No formal definition (yet), but there are several different sides: spacer
    Syntactic pattern:

               :: [Int] → Int
    f
    f[]        =0
    f (x : xs) = x + f xs




                                  Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Recognizing Patterns


 What constitutes a pattern?
    No formal definition (yet), but there are several different sides: spacer
    Syntactic pattern:

               :: [Int] → Int
    f
    f[]        =0
    f (x : xs) = x + f xs


    f = foldr (λx xs→x+xs) 0




                                  Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Recognizing Patterns


 What constitutes a pattern?
    No formal definition (yet), but there are several different sides: spacer
    Syntactic pattern:

               :: [Int] → Int
    f
    f[]        =0
    f (x : xs) = x + f xs


    f = foldr (λx xs→x+xs) 0

    Pure syntactic matching will not do, there need to be semantic
    restrictions:
          No recursion in base case (and even: what is a base
          case/recursive case?)
          Example: x should not be involved in recursive call
          What if more parameters are present in definition?
                                  Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Recognizing Patterns


 Generalizing patterns
    Previous pattern was specialized for lists.
    Alternative list
    data FastList a = Nil
                     | Cons a (FastList a)
                     | Unit   a
                     | Append (FastList a) (FastList a)


    Ideally, we want to recognize recursive definitions over arbitrary
    datatypes.
         Is there a general pattern? (e.g. for folds?)
         Even if so, do we want to give feedback? (There might be no fold
         for this datatype)
         Are there usecases for user-defined patterns?
         What about overlapping patterns in recursive definition?
                                  Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Feedback


 Constructing feedback
    Form of the feedback seems to be straightforward:
           Report improved definition of a naive recursive function




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Feedback


 Constructing feedback
    Form of the feedback seems to be straightforward:
           Report improved definition of a naive recursive function
    Why?
     1 Learn new constructs to user

     2 Enhance sense of beauty

     3 Using recursion primitives enhances maintainability

     4 Efficiency? (foldl vs. foldr )




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Feedback


 Constructing feedback
    Form of the feedback seems to be straightforward:
           Report improved definition of a naive recursive function
    Why?
     1 Learn new constructs to user

     2 Enhance sense of beauty

     3 Using recursion primitives enhances maintainability

     4 Efficiency? (foldl vs. foldr )

    Where and how:
           At compile time as ’warning’
           Alternatively: indicate in development environment (like Eclipse
           FP)
           Point to source location, or include original expression in feedback
           (or both)
                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Other applications


  Applications besides educational



    Are there other useful applications?




                                  Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Other applications


  Applications besides educational



    Are there other useful applications?


                                                  optimization


    Knowledge whether function is a fold (catamorphic) can be useful:
           To decide on inlining code (termination)
           Deforestation (Warm Fusion)




                                  Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 The Fun-language

    Small functional language based on expressions:
    Concrete syntax of expressions
    e ::= n                                                       constants
         |v                                                       variables
         | e1 ⊕ e2                                                infix operators
         | λp1 ...pn → e                                          lambda abstraction
         | fix v e                                                 function definition
         | e1 e2                                                  application
         | case v of p1 → e1 ; ... pn → en                        case analysis
         |[ ]                                                     empty list
         | e1 : e2                                                list constructor



                                 Center for Software Technology                   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 The Fun-language

    Small functional language based on expressions:
    Concrete syntax of expressions
    e ::= n                                                       constants
         |v                                                       variables
         | e1 ⊕ e2                                                infix operators
         | λp1 ...pn → e                                          lambda abstraction
         | fix v e                                                 function definition
         | e1 e2                                                  application
         |Concrete syntax of1 ; ... pn → en
           case v of p1 → e patterns                              case analysis
         |p ] v
           [ ::=                                                  empty list
                          binding
         | e1 : | p1 : p2 (nested) list
                e2                                                list constructor
                   |[ ]         empty list
                   |            wild card
                                 Center for Software Technology                   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Example recursive definition

    Haskell definition of sum
                 :: [Int] → Int
    sum
    sum [ ]      =0
    sum (x : xs) = x + sum xs

    Fun definition of sum
    fix sum λl → case l of [ ]    → 0;
                          x : xs → x + sum xs

           fix construct for recursive function definitions
           No pattern matching with multiple bodies in abstraction possible,
           an additional case expression is required

                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Main functionality

    Two main functions for analyzing an expression:
           suggest :: String → IO ()
           analyze :: Expr → Maybe Expr

    A number of assumptions have been made:
           A fixλcase construct appears at top-level
           Expressions to analyze are type correct
           Expressions do not contain shadowed identifiers
           Only (some) foldr patterns on lists are recognized...
                  ... and some experimental map patterns


    We will reflect on these assumptions later on.

                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Completeness and soundness

    We do not claim to be complete, nor is it our goal:
           Not recognizing a construct will never result in errors
           Not all suggestions are necessarily better
           What is the benchmark of completeness anyway?
           Each new construct adds complexity

    We do however want to be sound, every suggestion given should be
           Type correct
           Of the same type as the original expression
           Equal to original expression (extensional equality)
    And, everything we recognize is a valid recursion pattern


                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analyzing length



    lengthExpr : the length of a list
    fix length λl → case l of [ ]    → 0;
                             x : xs → 1 + length xs




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analyzing length



    lengthExpr : the length of a list
    fix length λl → case l of [ ]    → 0;
                             x : xs → 1 + length xs

    Suggested definition for length
    *FoldrRecognizer> suggest lengthExpr
    A more elegant solution would be:
    foldr (λ xs → 1 + xs) 0




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analyzing sum



    sumExpr : sum elements of list
    fix sum λl → case l of [ ]    → 0;
                          x : xs → x + sum xs




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analyzing sum



    sumExpr : sum elements of list
    fix sum λl → case l of [ ]    → 0;
                          x : xs → x + sum xs

    Suggested definition for sum
    *FoldrRecognizer> suggest sumExpr
    A more elegant solution would be:
    foldr (+) 0




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analyzing map


    mapExpr : mapping a function over a list
    fix map λf l → case l of [ ]    → [ ];
                            x : xs → f x : map f xs




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analyzing map


    mapExpr : mapping a function over a list
    fix map λf l → case l of [ ]    → [ ];
                            x : xs → f x : map f xs

    Suggested definition for map
    *FoldrRecognizer> suggest mapExpr
    A more elegant solution would be:
    λf → foldr (λx xs → f x : xs) [ ]

           Note that the definition of map is recognized, not the usage



                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analyzing append



    appendExpr : appending two lists ( + )
                                       +
    fix append λl1 l2 → case l1 of [ ]    → l2 ;
                                  x : xs → x : append xs l2




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analyzing append



    appendExpr : appending two lists ( + )
                                       +
    fix append λl1 l2 → case l1 of [ ]    → l2 ;
                                  x : xs → x : append xs l2

    Suggested definition for append
    *FoldrRecognizer> suggest appendExpr
    A more elegant solution would be:
    foldr (λx xs → λl2 → x : xs l2 ) (λl2 → l2 )




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Main algorithm



    The main algorithm consists of the following steps:
           Pre-process function definitions with multiple arguments
           Analyze that the definition can be written using foldr
           If so,
                  Construct the new definition using foldr
                  Post-process the returned lambda abstractions
                  Generate feedback
           Otherwise,
                  Generate feedback




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Pre-processing


    The analysis is based on a function with a single argument.
    Original definition of map
    fix map λf l → case l of [ ]    → [ ];
                            x : xs → f x : map f xs




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Pre-processing


    The analysis is based on a function with a single argument.
    Original definition of map
    fix map λf l → case l of [ ]    → [ ];
                            x : xs → f x : map f xs

    Pre-processed definition of map
    λf → fix map λl → case l of [ ]    → [ ];
                               x : xs → f x : map xs

           Arguments before the list argument are moved to the front



                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Pre-processing (2)


    The analysis is based on a function with a single argument.
    Original definition of append
    fix append λl1 l2 → case l1 of [ ]    → l2 ;
                                  x : xs → x : append xs l2




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Pre-processing (2)


    The analysis is based on a function with a single argument.
    Original definition of append
    fix append λl1 l2 → case l1 of [ ]    → l2 ;
                                  x : xs → x : append xs l2

    Pre-processed definition of append
      fix append λl1 → case l1 of [ ]    → λl2 → l2 ;
                                 x : xs → λl2 → x : append xs l2

           Arguments after the list argument are added to each case



                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Pre-processing (3)

    Moving all arguments to the front is semantically incorrect:
    Example definition
    fix weird λl1 l2 l3 → case l2 of [ ]    → l1 ;
                                    x : xs → append l3 (weird l1 xs l3 )




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Pre-processing (3)

    Moving all arguments to the front is semantically incorrect:
    Example definition
    fix weird λl1 l2 l3 → case l2 of [ ]    → l1 ;
                                    x : xs → append l3 (weird l1 xs l3 )

    Incorrect pre-processed definition of weird
    λl1 l3 → fix weird λl2 → case l2 of [ ]    → l1 ;
                                       x : xs → append l3 (weird xs)

           Order of arguments must remain unchanged!
           Rest of the algorithm is applied to the expression without the
           abstraction in front (it is added in the end)

                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Pre-processing (3)

    Moving all arguments to the front is semantically incorrect:
    Example definition
    fix weird λl1 l2 l3 → case l2 of [ ]    → l1 ;
                                    x : xs → append l3 (weird l1 xs l3 )

    Correct pre-processed definition of weird
    Incorrect pre-processed definition of weird
    λl1 →→ fix weird 2 →→ case l2 of] [ ] →→3 1→ l1 ;
        l3 fix weird λl λl2 case l2 of [         λl l ;
                                      x :xxs xs →3 → append l3 (weird xs l3 )
                                           : → λl append l3 (weird xs)

           Order of arguments must remain unchanged!
           Rest of the algorithm is applied to the expression without the
           abstraction in front (it is added in the end)

                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analysis
    Expressions can be defined using foldr iff:
           A fixλcase construct appears at top-level
           The case construct has exactly two cases
                  A base pattern ([ ])
                  A recursive pattern (x : xs)
           The base case does not use recursion
           The recursive case does use recursion
           The recursive case does not use the complete list argument

    fix tails λl → case l of [ ]    →[ ] : [ ]
                            x : xs → l : tails xs


    foldr (λx xs → l : xs) ([ ] : [ ])

                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Analysis (2)

    Properties defined compositionally for reuse:
    Recognizing a foldr
                  :: Expr → Bool
    isFoldr
    isFoldr expr = and (map ($ expr ) props)
      where props = [ isFunDef
                    , hasNrOfCases 2
                    , hasPattern isNilPat
                    , hasPattern isConsPat
                    , not . caseUses getBaseCase getFunIdent
                    , caseUses getRecCase getFunIdent
                    , not . caseUses getRecCase getCaseArg
                    ]


                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Constructing a new definition

    Body of cases (almost) directly map to arguments of foldr :
           Body of base case is 2nd argument of foldr
           Body of recursive case is 1st argument of foldr , but requires:
                  Replacing recursive call with the tail of the original argument list

    Pre-processed definition of append
      fix append λl1 → case l1 of [ ]    → λl2 → l2 ;
                                 x : xs → λl2 → x : append xs l2




                                 Center for Software Technology        Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Constructing a new definition

    Body of cases (almost) directly map to arguments of foldr :
           Body of base case is 2nd argument of foldr
           Body of recursive case is 1st argument of foldr , but requires:
                  Replacing recursive call with the tail of the original argument list

    Pre-processed definition of append
      fix append λl1 → case l1 of [ ]    → λl2 → l2 ;
                                 x : xs → λl2 → x : append xs l2




                                 Center for Software Technology        Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Constructing a new definition

    Body of cases (almost) directly map to arguments of foldr :
           Body of base case is 2nd argument of foldr
           Body of recursive case is 1st argument of foldr , but requires:
                  Replacing recursive call with the tail of the original argument list

    Pre-processed definition of append
      fix append λl1 → case l1 of [ ]    → λl2 → l2 ;
                                 x : xs → λl2 → x : append xs l2




                                 Center for Software Technology        Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Constructing a new definition

    Body of cases (almost) directly map to arguments of foldr :
           Body of base case is 2nd argument of foldr
           Body of recursive case is 1st argument of foldr , but requires:
                  Replacing recursive call with the tail of the original argument list

    Pre-processed definition of append
      fix append λl1 → case l1 of [ ]    → λl2 → l2 ;
                                 x : xs → λl2 → x : append xs l2




                                 Center for Software Technology        Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Constructing a new definition

    Body of cases (almost) directly map to arguments of foldr :
           Body of base case is 2nd argument of foldr
           Body of recursive case is 1st argument of foldr , but requires:
                  Replacing recursive call with the tail of the original argument list

    Pre-processed definition of append
      fix append λl1 → case l1 of [ ]    → λl2 → l2 ;
                                 x : xs → λl2 → x : append xs l2

    New definition of append
    foldr (λx xs → λl2 → x : xs l2 ) (λl2 → l2 )



                                 Center for Software Technology        Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Post-processing
    Derived arguments of a call to foldr can be simplified:
         Infix operators
    Suggested definition for sum
    foldr (λx xs → x + xs) 0

    Simplified definition of sum
    foldr (+) 0




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Post-processing
    Derived arguments of a call to foldr can be simplified:
         Infix operators
    Suggested definition for sum
    foldr (λx xs → x + xs) 0

    Simplified definition of sum
    foldr (+) 0

           Function applications
    Suggested definition for concat
    foldr (λx xs → append x xs) [ ]

    Simplified definition of concat
    foldr append [ ]
                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Post-processing (2)
           Collapsing lambda abstractions (not implemented yet)
    Suggested definition for append
    foldr (λx xs → λl2 → x : xs l2 ) (λl2 → l2 )

    Simplified definition of append
    foldr (λx xs l2 → x : xs l2 ) (λl2 → l2 )




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Implementation


 Post-processing (2)
           Collapsing lambda abstractions (not implemented yet)
    Suggested definition for append
    foldr (λx xs → λl2 → x : xs l2 ) (λl2 → l2 )

    Simplified definition of append
    foldr (λx xs l2 → x : xs l2 ) (λl2 → l2 )

           Replacing unused bindings with wild card
    Suggested definition for length
    foldr (λx xs → 1 + xs) 0

    Simplified definition of length
    foldr (λ xs → 1 + xs) 0

                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Related Work


 Dr. Haskell

    A tool to detect common patterns in Haskell code:
    Example definition
    f n x = take n (repeat x)

    Suggestion
    f n x = replicate n x


    Implemented by normalizing code and matching hard-coded patterns:
    Defined pattern
    use replicate n x = take n (repeat x)


                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Related Work


 Dr. Haskell (2)


    Developed by Neil Mitchell at the University of York
           Implemented using Yhc
           Only recognizes patterns in function application...
                  ... and lacks recognizing patterns in function definitions
           Only based on syntactic restrictions...
                  ... and lacks semantic restrictions
           Only points to source location which matches a pattern...
                  ... instead of giving a suggestion


    Not really suited for recognizing recursion patterns in general



                                 Center for Software Technology      Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Conclusion


 General observations
    The current implementation is restricted to:
           Expressions without shadowed identifiers
           Recognizing (some) foldr patterns on lists, reusability of certain
           components has yet to be proven
           Expressions with a fixλcase construct at top-level
           Simplifying just some lambda abstractions
           Always just returning a more ’elegant’ solution, although this is
           not always the case
    Suggested definition for weird
    λl1 → foldr (λ xs → λl3 → append l3 (xs l3 )) (λl3 → l1 )


    The implementation is not complete at all, but believed to be sound...
                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Conclusion


 Future work


    First thing to do, try to recognize other recursion patterns:
           Is is easy to implement recognizing other recursion patterns?
           What parts can be reused?
           Is there a general structure which can be abstracted over?


    Keeping quality of feedback in mind of course...
           Which suggestions are shown?
           Reducing the complexity of the suggestions by simplifying




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Conclusion


 Concluding remarks


           No supporting theory available, so our approach consists of
                   Trial-and-error
                   Use of unit tests
                   Lots of hard thinking...
           Translation to mature language
                   Requires normalisation of expressions to be analyzed
                   Normalisation should not interfere with feedback
                   Giving feedback requires pointing to source location
           Lambda simplification improves the quality of feedback
           Current feedback would already be useful for 1st -year FP students




                                 Center for Software Technology      Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Conclusion


 Discussion




           Should prelude functions (e.g. const, flip and id) be used in our
           feedback?




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Conclusion


 Discussion




           Should prelude functions (e.g. const, flip and id) be used in our
           feedback?
           What determines the complexity of a suggestion?




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Conclusion


 Discussion




           Should prelude functions (e.g. const, flip and id) be used in our
           feedback?
           What determines the complexity of a suggestion?
           Would you expand detection to arbitrary datatypes (width) or
           expand by adding new patterns over the List-datatype (depth)?




                                 Center for Software Technology   Sander Mak, Thomas van Noort
Recursion Pattern Analysis and Feedback > Conclusion


 Discussion




           Should prelude functions (e.g. const, flip and id) be used in our
           feedback?
           What determines the complexity of a suggestion?
           Would you expand detection to arbitrary datatypes (width) or
           expand by adding new patterns over the List-datatype (depth)?
           Which patterns would be useful to detect?




                                 Center for Software Technology   Sander Mak, Thomas van Noort

Más contenido relacionado

La actualidad más candente

Recursion(Advanced data structure)
Recursion(Advanced data structure)Recursion(Advanced data structure)
Recursion(Advanced data structure)kurubameena1
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresPriyanka Rana
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructuresNguync91368
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to AlgorithmsVenkatesh Iyer
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Algorithm & data structures lec1
Algorithm & data structures lec1Algorithm & data structures lec1
Algorithm & data structures lec1Abdul Khan
 
On Applying Or-Parallelism and Tabling to Logic Programs
On Applying Or-Parallelism and Tabling to Logic ProgramsOn Applying Or-Parallelism and Tabling to Logic Programs
On Applying Or-Parallelism and Tabling to Logic ProgramsLino Possamai
 
Programming in python
Programming in pythonProgramming in python
Programming in pythonIvan Rojas
 
CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsKrishnan MuthuManickam
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and reviewAbdullah Al-hazmy
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsAbdullah Al-hazmy
 
Introduction to Data Structures & Algorithms
Introduction to Data Structures & AlgorithmsIntroduction to Data Structures & Algorithms
Introduction to Data Structures & AlgorithmsAfaq Mansoor Khan
 
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisDetecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisSilvio Cesare
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAmrinder Arora
 

La actualidad más candente (20)

Recursion(Advanced data structure)
Recursion(Advanced data structure)Recursion(Advanced data structure)
Recursion(Advanced data structure)
 
Chapter 6 ds
Chapter 6 dsChapter 6 ds
Chapter 6 ds
 
2 b queues
2 b queues2 b queues
2 b queues
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data Structures
 
2 a stacks
2 a stacks2 a stacks
2 a stacks
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
Chapter 11 ds
Chapter 11 dsChapter 11 ds
Chapter 11 ds
 
Data structures
Data structuresData structures
Data structures
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
 
Algorithm & data structures lec1
Algorithm & data structures lec1Algorithm & data structures lec1
Algorithm & data structures lec1
 
On Applying Or-Parallelism and Tabling to Logic Programs
On Applying Or-Parallelism and Tabling to Logic ProgramsOn Applying Or-Parallelism and Tabling to Logic Programs
On Applying Or-Parallelism and Tabling to Logic Programs
 
Programming in python
Programming in pythonProgramming in python
Programming in python
 
CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of Algorithms
 
introduction
introductionintroduction
introduction
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
 
Introduction to Data Structures & Algorithms
Introduction to Data Structures & AlgorithmsIntroduction to Data Structures & Algorithms
Introduction to Data Structures & Algorithms
 
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisDetecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data Structures
 

Destacado

9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Types Of Recursion in C++, Data Stuctures by DHEERAJ KATARIA
Types Of Recursion in C++, Data Stuctures by DHEERAJ KATARIATypes Of Recursion in C++, Data Stuctures by DHEERAJ KATARIA
Types Of Recursion in C++, Data Stuctures by DHEERAJ KATARIADheeraj Kataria
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursionAbdullah Al-hazmy
 

Destacado (6)

Tail recursion
Tail recursionTail recursion
Tail recursion
 
Recursion in c++
Recursion in c++Recursion in c++
Recursion in c++
 
1 Recur
1 Recur1 Recur
1 Recur
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
 
Types Of Recursion in C++, Data Stuctures by DHEERAJ KATARIA
Types Of Recursion in C++, Data Stuctures by DHEERAJ KATARIATypes Of Recursion in C++, Data Stuctures by DHEERAJ KATARIA
Types Of Recursion in C++, Data Stuctures by DHEERAJ KATARIA
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 

Similar a Recursion Pattern Analysis and Feedback

From programming to software engineering: ICSE keynote slides available
From programming to software engineering: ICSE keynote slides availableFrom programming to software engineering: ICSE keynote slides available
From programming to software engineering: ICSE keynote slides availableCelso Martins
 
Models vs Reality: Quest for the Roots of Complexity
Models vs Reality: Quest for the Roots of ComplexityModels vs Reality: Quest for the Roots of Complexity
Models vs Reality: Quest for the Roots of ComplexityJulian Warszawski
 
VRP2013 - Comp Aspects VRP
VRP2013 - Comp Aspects VRPVRP2013 - Comp Aspects VRP
VRP2013 - Comp Aspects VRPVictor Pillac
 
Scala for Machine Learning
Scala for Machine LearningScala for Machine Learning
Scala for Machine LearningPatrick Nicolas
 
PL Lecture 01 - preliminaries
PL Lecture 01 - preliminariesPL Lecture 01 - preliminaries
PL Lecture 01 - preliminariesSchwannden Kuo
 
And Then There Are Algorithms - Danilo Poccia - Codemotion Rome 2018
And Then There Are Algorithms - Danilo Poccia - Codemotion Rome 2018And Then There Are Algorithms - Danilo Poccia - Codemotion Rome 2018
And Then There Are Algorithms - Danilo Poccia - Codemotion Rome 2018Codemotion
 
On the Semantics of Real-Time Domain Specific Modeling Languages
On the Semantics of Real-Time Domain Specific Modeling LanguagesOn the Semantics of Real-Time Domain Specific Modeling Languages
On the Semantics of Real-Time Domain Specific Modeling LanguagesJose E. Rivera
 
LISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesLISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesDominic Graefen
 
Multimodal Learning Analytics
Multimodal Learning AnalyticsMultimodal Learning Analytics
Multimodal Learning AnalyticsXavier Ochoa
 
Methodological study of opinion mining and sentiment analysis techniques
Methodological study of opinion mining and sentiment analysis techniquesMethodological study of opinion mining and sentiment analysis techniques
Methodological study of opinion mining and sentiment analysis techniquesijsc
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming ParadigmsDirecti Group
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming ParadigmsJaneve George
 
End-to-End Memory Networks with Knowledge Carryover for Multi-Turn Spoken Lan...
End-to-End Memory Networks with Knowledge Carryover for Multi-Turn Spoken Lan...End-to-End Memory Networks with Knowledge Carryover for Multi-Turn Spoken Lan...
End-to-End Memory Networks with Knowledge Carryover for Multi-Turn Spoken Lan...Yun-Nung (Vivian) Chen
 
ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyTypesafe
 

Similar a Recursion Pattern Analysis and Feedback (20)

From programming to software engineering: ICSE keynote slides available
From programming to software engineering: ICSE keynote slides availableFrom programming to software engineering: ICSE keynote slides available
From programming to software engineering: ICSE keynote slides available
 
Models vs Reality: Quest for the Roots of Complexity
Models vs Reality: Quest for the Roots of ComplexityModels vs Reality: Quest for the Roots of Complexity
Models vs Reality: Quest for the Roots of Complexity
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
 
Presentation
PresentationPresentation
Presentation
 
VRP2013 - Comp Aspects VRP
VRP2013 - Comp Aspects VRPVRP2013 - Comp Aspects VRP
VRP2013 - Comp Aspects VRP
 
Scala for Machine Learning
Scala for Machine LearningScala for Machine Learning
Scala for Machine Learning
 
PL Lecture 01 - preliminaries
PL Lecture 01 - preliminariesPL Lecture 01 - preliminaries
PL Lecture 01 - preliminaries
 
And Then There Are Algorithms - Danilo Poccia - Codemotion Rome 2018
And Then There Are Algorithms - Danilo Poccia - Codemotion Rome 2018And Then There Are Algorithms - Danilo Poccia - Codemotion Rome 2018
And Then There Are Algorithms - Danilo Poccia - Codemotion Rome 2018
 
On the Semantics of Real-Time Domain Specific Modeling Languages
On the Semantics of Real-Time Domain Specific Modeling LanguagesOn the Semantics of Real-Time Domain Specific Modeling Languages
On the Semantics of Real-Time Domain Specific Modeling Languages
 
LISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesLISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love Parantheses
 
Multimodal Learning Analytics
Multimodal Learning AnalyticsMultimodal Learning Analytics
Multimodal Learning Analytics
 
ASE02.ppt
ASE02.pptASE02.ppt
ASE02.ppt
 
Methodological study of opinion mining and sentiment analysis techniques
Methodological study of opinion mining and sentiment analysis techniquesMethodological study of opinion mining and sentiment analysis techniques
Methodological study of opinion mining and sentiment analysis techniques
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
 
End-to-End Memory Networks with Knowledge Carryover for Multi-Turn Spoken Lan...
End-to-End Memory Networks with Knowledge Carryover for Multi-Turn Spoken Lan...End-to-End Memory Networks with Knowledge Carryover for Multi-Turn Spoken Lan...
End-to-End Memory Networks with Knowledge Carryover for Multi-Turn Spoken Lan...
 
Java and Deep Learning
Java and Deep LearningJava and Deep Learning
Java and Deep Learning
 
AI and Deep Learning
AI and Deep Learning AI and Deep Learning
AI and Deep Learning
 
ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin Odersky
 

Más de Sander Mak (@Sander_Mak)

TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painSander Mak (@Sander_Mak)
 
The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)Sander Mak (@Sander_Mak)
 
Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?Sander Mak (@Sander_Mak)
 
Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Sander Mak (@Sander_Mak)
 

Más de Sander Mak (@Sander_Mak) (20)

Scalable Application Development @ Picnic
Scalable Application Development @ PicnicScalable Application Development @ Picnic
Scalable Application Development @ Picnic
 
Coding Your Way to Java 13
Coding Your Way to Java 13Coding Your Way to Java 13
Coding Your Way to Java 13
 
Coding Your Way to Java 12
Coding Your Way to Java 12Coding Your Way to Java 12
Coding Your Way to Java 12
 
Java Modularity: the Year After
Java Modularity: the Year AfterJava Modularity: the Year After
Java Modularity: the Year After
 
Desiging for Modularity with Java 9
Desiging for Modularity with Java 9Desiging for Modularity with Java 9
Desiging for Modularity with Java 9
 
Modules or microservices?
Modules or microservices?Modules or microservices?
Modules or microservices?
 
Migrating to Java 9 Modules
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 Modules
 
Java 9 Modularity in Action
Java 9 Modularity in ActionJava 9 Modularity in Action
Java 9 Modularity in Action
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 9
 
Provisioning the IoT
Provisioning the IoTProvisioning the IoT
Provisioning the IoT
 
Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
 
The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)
 
Modular JavaScript
Modular JavaScriptModular JavaScript
Modular JavaScript
 
Modularity in the Cloud
Modularity in the CloudModularity in the Cloud
Modularity in the Cloud
 
Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?
 
Scala & Lift (JEEConf 2012)
Scala & Lift (JEEConf 2012)Scala & Lift (JEEConf 2012)
Scala & Lift (JEEConf 2012)
 
Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)
 
Akka (BeJUG)
Akka (BeJUG)Akka (BeJUG)
Akka (BeJUG)
 
Fork Join (BeJUG 2012)
Fork Join (BeJUG 2012)Fork Join (BeJUG 2012)
Fork Join (BeJUG 2012)
 

Último

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Último (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

Recursion Pattern Analysis and Feedback

  • 1. Recursion Pattern Analysis and Feedback Recursion Pattern Analysis and Feedback Sander Mak Thomas van Noort Center for Software Technology, Universiteit Utrecht October 27, 2006 Center for Software Technology Sander Mak, Thomas van Noort
  • 2. Recursion Pattern Analysis and Feedback Overview Introduction 1 Recognizing Patterns 2 Feedback 3 Other applications 4 Implementation 5 Related Work 6 Conclusion 7 Center for Software Technology Sander Mak, Thomas van Noort
  • 3. Recursion Pattern Analysis and Feedback > Introduction Why focus on recursion? Recursion is an essential part of Haskell: it is the only way to loop or iterate spacer Center for Software Technology Sander Mak, Thomas van Noort
  • 4. Recursion Pattern Analysis and Feedback > Introduction Why focus on recursion? Recursion is an essential part of Haskell: it is the only way to loop or iterate spacer Sometimes this message is taken to heart. Or too hard... Naive recursion f[] =1 f (x : xs) = (x + 1) ∗ f xs Center for Software Technology Sander Mak, Thomas van Noort
  • 5. Recursion Pattern Analysis and Feedback > Introduction Why focus on recursion? Recursion is an essential part of Haskell: it is the only way to loop or iterate spacer Sometimes this message is taken to heart. Or too hard... Naive recursion f[] =1 f (x : xs) = (x + 1) ∗ f xs Pretty recursion f = foldr (∗) 1 . map (+1) or : f = foldr (λ x xs → (x + 1) ∗ xs) 1 Center for Software Technology Sander Mak, Thomas van Noort
  • 6. Recursion Pattern Analysis and Feedback > Introduction Our goal Eliminate Haskell-recursion illiteracy: IRC transcript <CosmicRay> so let’s say I’m writing a recursive function like this: <CosmicRay> myFoo [] = [] <CosmicRay> myFoo (x:xs) = (x + 5) : myFoo xs <JaffaCake> i.e. map (+5) <CosmicRay> right, but I don’t know how map works internally, so I wrote it out <JaffaCake> it works just like that ;) spacer (and improve life for Bastiaan by doing so) Center for Software Technology Sander Mak, Thomas van Noort
  • 7. Recursion Pattern Analysis and Feedback > Introduction Research questions Improvement of recursive definitions is quite a broad goal. More concrete sub-questions are: Which recursion combinators are available? Usual suspects: foldr , map But also: filter , foldl, etc. Which patterns do we want to recognize? Are some functions better of in a naive definition? Where are recursion patterns described? How do we present these improvements? Where do we present these improvements? Center for Software Technology Sander Mak, Thomas van Noort
  • 8. Recursion Pattern Analysis and Feedback > Recognizing Patterns What constitutes a pattern? No formal definition (yet), but there are several different sides: spacer Syntactic pattern: :: [Int] → Int f f[] =0 f (x : xs) = x + f xs Center for Software Technology Sander Mak, Thomas van Noort
  • 9. Recursion Pattern Analysis and Feedback > Recognizing Patterns What constitutes a pattern? No formal definition (yet), but there are several different sides: spacer Syntactic pattern: :: [Int] → Int f f[] =0 f (x : xs) = x + f xs Center for Software Technology Sander Mak, Thomas van Noort
  • 10. Recursion Pattern Analysis and Feedback > Recognizing Patterns What constitutes a pattern? No formal definition (yet), but there are several different sides: spacer Syntactic pattern: :: [Int] → Int f f[] =0 f (x : xs) = x + f xs f = foldr (λx xs→x+xs) 0 Center for Software Technology Sander Mak, Thomas van Noort
  • 11. Recursion Pattern Analysis and Feedback > Recognizing Patterns What constitutes a pattern? No formal definition (yet), but there are several different sides: spacer Syntactic pattern: :: [Int] → Int f f[] =0 f (x : xs) = x + f xs f = foldr (λx xs→x+xs) 0 Pure syntactic matching will not do, there need to be semantic restrictions: No recursion in base case (and even: what is a base case/recursive case?) Example: x should not be involved in recursive call What if more parameters are present in definition? Center for Software Technology Sander Mak, Thomas van Noort
  • 12. Recursion Pattern Analysis and Feedback > Recognizing Patterns Generalizing patterns Previous pattern was specialized for lists. Alternative list data FastList a = Nil | Cons a (FastList a) | Unit a | Append (FastList a) (FastList a) Ideally, we want to recognize recursive definitions over arbitrary datatypes. Is there a general pattern? (e.g. for folds?) Even if so, do we want to give feedback? (There might be no fold for this datatype) Are there usecases for user-defined patterns? What about overlapping patterns in recursive definition? Center for Software Technology Sander Mak, Thomas van Noort
  • 13. Recursion Pattern Analysis and Feedback > Feedback Constructing feedback Form of the feedback seems to be straightforward: Report improved definition of a naive recursive function Center for Software Technology Sander Mak, Thomas van Noort
  • 14. Recursion Pattern Analysis and Feedback > Feedback Constructing feedback Form of the feedback seems to be straightforward: Report improved definition of a naive recursive function Why? 1 Learn new constructs to user 2 Enhance sense of beauty 3 Using recursion primitives enhances maintainability 4 Efficiency? (foldl vs. foldr ) Center for Software Technology Sander Mak, Thomas van Noort
  • 15. Recursion Pattern Analysis and Feedback > Feedback Constructing feedback Form of the feedback seems to be straightforward: Report improved definition of a naive recursive function Why? 1 Learn new constructs to user 2 Enhance sense of beauty 3 Using recursion primitives enhances maintainability 4 Efficiency? (foldl vs. foldr ) Where and how: At compile time as ’warning’ Alternatively: indicate in development environment (like Eclipse FP) Point to source location, or include original expression in feedback (or both) Center for Software Technology Sander Mak, Thomas van Noort
  • 16. Recursion Pattern Analysis and Feedback > Other applications Applications besides educational Are there other useful applications? Center for Software Technology Sander Mak, Thomas van Noort
  • 17. Recursion Pattern Analysis and Feedback > Other applications Applications besides educational Are there other useful applications? optimization Knowledge whether function is a fold (catamorphic) can be useful: To decide on inlining code (termination) Deforestation (Warm Fusion) Center for Software Technology Sander Mak, Thomas van Noort
  • 18. Recursion Pattern Analysis and Feedback > Implementation The Fun-language Small functional language based on expressions: Concrete syntax of expressions e ::= n constants |v variables | e1 ⊕ e2 infix operators | λp1 ...pn → e lambda abstraction | fix v e function definition | e1 e2 application | case v of p1 → e1 ; ... pn → en case analysis |[ ] empty list | e1 : e2 list constructor Center for Software Technology Sander Mak, Thomas van Noort
  • 19. Recursion Pattern Analysis and Feedback > Implementation The Fun-language Small functional language based on expressions: Concrete syntax of expressions e ::= n constants |v variables | e1 ⊕ e2 infix operators | λp1 ...pn → e lambda abstraction | fix v e function definition | e1 e2 application |Concrete syntax of1 ; ... pn → en case v of p1 → e patterns case analysis |p ] v [ ::= empty list binding | e1 : | p1 : p2 (nested) list e2 list constructor |[ ] empty list | wild card Center for Software Technology Sander Mak, Thomas van Noort
  • 20. Recursion Pattern Analysis and Feedback > Implementation Example recursive definition Haskell definition of sum :: [Int] → Int sum sum [ ] =0 sum (x : xs) = x + sum xs Fun definition of sum fix sum λl → case l of [ ] → 0; x : xs → x + sum xs fix construct for recursive function definitions No pattern matching with multiple bodies in abstraction possible, an additional case expression is required Center for Software Technology Sander Mak, Thomas van Noort
  • 21. Recursion Pattern Analysis and Feedback > Implementation Main functionality Two main functions for analyzing an expression: suggest :: String → IO () analyze :: Expr → Maybe Expr A number of assumptions have been made: A fixλcase construct appears at top-level Expressions to analyze are type correct Expressions do not contain shadowed identifiers Only (some) foldr patterns on lists are recognized... ... and some experimental map patterns We will reflect on these assumptions later on. Center for Software Technology Sander Mak, Thomas van Noort
  • 22. Recursion Pattern Analysis and Feedback > Implementation Completeness and soundness We do not claim to be complete, nor is it our goal: Not recognizing a construct will never result in errors Not all suggestions are necessarily better What is the benchmark of completeness anyway? Each new construct adds complexity We do however want to be sound, every suggestion given should be Type correct Of the same type as the original expression Equal to original expression (extensional equality) And, everything we recognize is a valid recursion pattern Center for Software Technology Sander Mak, Thomas van Noort
  • 23. Recursion Pattern Analysis and Feedback > Implementation Analyzing length lengthExpr : the length of a list fix length λl → case l of [ ] → 0; x : xs → 1 + length xs Center for Software Technology Sander Mak, Thomas van Noort
  • 24. Recursion Pattern Analysis and Feedback > Implementation Analyzing length lengthExpr : the length of a list fix length λl → case l of [ ] → 0; x : xs → 1 + length xs Suggested definition for length *FoldrRecognizer> suggest lengthExpr A more elegant solution would be: foldr (λ xs → 1 + xs) 0 Center for Software Technology Sander Mak, Thomas van Noort
  • 25. Recursion Pattern Analysis and Feedback > Implementation Analyzing sum sumExpr : sum elements of list fix sum λl → case l of [ ] → 0; x : xs → x + sum xs Center for Software Technology Sander Mak, Thomas van Noort
  • 26. Recursion Pattern Analysis and Feedback > Implementation Analyzing sum sumExpr : sum elements of list fix sum λl → case l of [ ] → 0; x : xs → x + sum xs Suggested definition for sum *FoldrRecognizer> suggest sumExpr A more elegant solution would be: foldr (+) 0 Center for Software Technology Sander Mak, Thomas van Noort
  • 27. Recursion Pattern Analysis and Feedback > Implementation Analyzing map mapExpr : mapping a function over a list fix map λf l → case l of [ ] → [ ]; x : xs → f x : map f xs Center for Software Technology Sander Mak, Thomas van Noort
  • 28. Recursion Pattern Analysis and Feedback > Implementation Analyzing map mapExpr : mapping a function over a list fix map λf l → case l of [ ] → [ ]; x : xs → f x : map f xs Suggested definition for map *FoldrRecognizer> suggest mapExpr A more elegant solution would be: λf → foldr (λx xs → f x : xs) [ ] Note that the definition of map is recognized, not the usage Center for Software Technology Sander Mak, Thomas van Noort
  • 29. Recursion Pattern Analysis and Feedback > Implementation Analyzing append appendExpr : appending two lists ( + ) + fix append λl1 l2 → case l1 of [ ] → l2 ; x : xs → x : append xs l2 Center for Software Technology Sander Mak, Thomas van Noort
  • 30. Recursion Pattern Analysis and Feedback > Implementation Analyzing append appendExpr : appending two lists ( + ) + fix append λl1 l2 → case l1 of [ ] → l2 ; x : xs → x : append xs l2 Suggested definition for append *FoldrRecognizer> suggest appendExpr A more elegant solution would be: foldr (λx xs → λl2 → x : xs l2 ) (λl2 → l2 ) Center for Software Technology Sander Mak, Thomas van Noort
  • 31. Recursion Pattern Analysis and Feedback > Implementation Main algorithm The main algorithm consists of the following steps: Pre-process function definitions with multiple arguments Analyze that the definition can be written using foldr If so, Construct the new definition using foldr Post-process the returned lambda abstractions Generate feedback Otherwise, Generate feedback Center for Software Technology Sander Mak, Thomas van Noort
  • 32. Recursion Pattern Analysis and Feedback > Implementation Pre-processing The analysis is based on a function with a single argument. Original definition of map fix map λf l → case l of [ ] → [ ]; x : xs → f x : map f xs Center for Software Technology Sander Mak, Thomas van Noort
  • 33. Recursion Pattern Analysis and Feedback > Implementation Pre-processing The analysis is based on a function with a single argument. Original definition of map fix map λf l → case l of [ ] → [ ]; x : xs → f x : map f xs Pre-processed definition of map λf → fix map λl → case l of [ ] → [ ]; x : xs → f x : map xs Arguments before the list argument are moved to the front Center for Software Technology Sander Mak, Thomas van Noort
  • 34. Recursion Pattern Analysis and Feedback > Implementation Pre-processing (2) The analysis is based on a function with a single argument. Original definition of append fix append λl1 l2 → case l1 of [ ] → l2 ; x : xs → x : append xs l2 Center for Software Technology Sander Mak, Thomas van Noort
  • 35. Recursion Pattern Analysis and Feedback > Implementation Pre-processing (2) The analysis is based on a function with a single argument. Original definition of append fix append λl1 l2 → case l1 of [ ] → l2 ; x : xs → x : append xs l2 Pre-processed definition of append fix append λl1 → case l1 of [ ] → λl2 → l2 ; x : xs → λl2 → x : append xs l2 Arguments after the list argument are added to each case Center for Software Technology Sander Mak, Thomas van Noort
  • 36. Recursion Pattern Analysis and Feedback > Implementation Pre-processing (3) Moving all arguments to the front is semantically incorrect: Example definition fix weird λl1 l2 l3 → case l2 of [ ] → l1 ; x : xs → append l3 (weird l1 xs l3 ) Center for Software Technology Sander Mak, Thomas van Noort
  • 37. Recursion Pattern Analysis and Feedback > Implementation Pre-processing (3) Moving all arguments to the front is semantically incorrect: Example definition fix weird λl1 l2 l3 → case l2 of [ ] → l1 ; x : xs → append l3 (weird l1 xs l3 ) Incorrect pre-processed definition of weird λl1 l3 → fix weird λl2 → case l2 of [ ] → l1 ; x : xs → append l3 (weird xs) Order of arguments must remain unchanged! Rest of the algorithm is applied to the expression without the abstraction in front (it is added in the end) Center for Software Technology Sander Mak, Thomas van Noort
  • 38. Recursion Pattern Analysis and Feedback > Implementation Pre-processing (3) Moving all arguments to the front is semantically incorrect: Example definition fix weird λl1 l2 l3 → case l2 of [ ] → l1 ; x : xs → append l3 (weird l1 xs l3 ) Correct pre-processed definition of weird Incorrect pre-processed definition of weird λl1 →→ fix weird 2 →→ case l2 of] [ ] →→3 1→ l1 ; l3 fix weird λl λl2 case l2 of [ λl l ; x :xxs xs →3 → append l3 (weird xs l3 ) : → λl append l3 (weird xs) Order of arguments must remain unchanged! Rest of the algorithm is applied to the expression without the abstraction in front (it is added in the end) Center for Software Technology Sander Mak, Thomas van Noort
  • 39. Recursion Pattern Analysis and Feedback > Implementation Analysis Expressions can be defined using foldr iff: A fixλcase construct appears at top-level The case construct has exactly two cases A base pattern ([ ]) A recursive pattern (x : xs) The base case does not use recursion The recursive case does use recursion The recursive case does not use the complete list argument fix tails λl → case l of [ ] →[ ] : [ ] x : xs → l : tails xs foldr (λx xs → l : xs) ([ ] : [ ]) Center for Software Technology Sander Mak, Thomas van Noort
  • 40. Recursion Pattern Analysis and Feedback > Implementation Analysis (2) Properties defined compositionally for reuse: Recognizing a foldr :: Expr → Bool isFoldr isFoldr expr = and (map ($ expr ) props) where props = [ isFunDef , hasNrOfCases 2 , hasPattern isNilPat , hasPattern isConsPat , not . caseUses getBaseCase getFunIdent , caseUses getRecCase getFunIdent , not . caseUses getRecCase getCaseArg ] Center for Software Technology Sander Mak, Thomas van Noort
  • 41. Recursion Pattern Analysis and Feedback > Implementation Constructing a new definition Body of cases (almost) directly map to arguments of foldr : Body of base case is 2nd argument of foldr Body of recursive case is 1st argument of foldr , but requires: Replacing recursive call with the tail of the original argument list Pre-processed definition of append fix append λl1 → case l1 of [ ] → λl2 → l2 ; x : xs → λl2 → x : append xs l2 Center for Software Technology Sander Mak, Thomas van Noort
  • 42. Recursion Pattern Analysis and Feedback > Implementation Constructing a new definition Body of cases (almost) directly map to arguments of foldr : Body of base case is 2nd argument of foldr Body of recursive case is 1st argument of foldr , but requires: Replacing recursive call with the tail of the original argument list Pre-processed definition of append fix append λl1 → case l1 of [ ] → λl2 → l2 ; x : xs → λl2 → x : append xs l2 Center for Software Technology Sander Mak, Thomas van Noort
  • 43. Recursion Pattern Analysis and Feedback > Implementation Constructing a new definition Body of cases (almost) directly map to arguments of foldr : Body of base case is 2nd argument of foldr Body of recursive case is 1st argument of foldr , but requires: Replacing recursive call with the tail of the original argument list Pre-processed definition of append fix append λl1 → case l1 of [ ] → λl2 → l2 ; x : xs → λl2 → x : append xs l2 Center for Software Technology Sander Mak, Thomas van Noort
  • 44. Recursion Pattern Analysis and Feedback > Implementation Constructing a new definition Body of cases (almost) directly map to arguments of foldr : Body of base case is 2nd argument of foldr Body of recursive case is 1st argument of foldr , but requires: Replacing recursive call with the tail of the original argument list Pre-processed definition of append fix append λl1 → case l1 of [ ] → λl2 → l2 ; x : xs → λl2 → x : append xs l2 Center for Software Technology Sander Mak, Thomas van Noort
  • 45. Recursion Pattern Analysis and Feedback > Implementation Constructing a new definition Body of cases (almost) directly map to arguments of foldr : Body of base case is 2nd argument of foldr Body of recursive case is 1st argument of foldr , but requires: Replacing recursive call with the tail of the original argument list Pre-processed definition of append fix append λl1 → case l1 of [ ] → λl2 → l2 ; x : xs → λl2 → x : append xs l2 New definition of append foldr (λx xs → λl2 → x : xs l2 ) (λl2 → l2 ) Center for Software Technology Sander Mak, Thomas van Noort
  • 46. Recursion Pattern Analysis and Feedback > Implementation Post-processing Derived arguments of a call to foldr can be simplified: Infix operators Suggested definition for sum foldr (λx xs → x + xs) 0 Simplified definition of sum foldr (+) 0 Center for Software Technology Sander Mak, Thomas van Noort
  • 47. Recursion Pattern Analysis and Feedback > Implementation Post-processing Derived arguments of a call to foldr can be simplified: Infix operators Suggested definition for sum foldr (λx xs → x + xs) 0 Simplified definition of sum foldr (+) 0 Function applications Suggested definition for concat foldr (λx xs → append x xs) [ ] Simplified definition of concat foldr append [ ] Center for Software Technology Sander Mak, Thomas van Noort
  • 48. Recursion Pattern Analysis and Feedback > Implementation Post-processing (2) Collapsing lambda abstractions (not implemented yet) Suggested definition for append foldr (λx xs → λl2 → x : xs l2 ) (λl2 → l2 ) Simplified definition of append foldr (λx xs l2 → x : xs l2 ) (λl2 → l2 ) Center for Software Technology Sander Mak, Thomas van Noort
  • 49. Recursion Pattern Analysis and Feedback > Implementation Post-processing (2) Collapsing lambda abstractions (not implemented yet) Suggested definition for append foldr (λx xs → λl2 → x : xs l2 ) (λl2 → l2 ) Simplified definition of append foldr (λx xs l2 → x : xs l2 ) (λl2 → l2 ) Replacing unused bindings with wild card Suggested definition for length foldr (λx xs → 1 + xs) 0 Simplified definition of length foldr (λ xs → 1 + xs) 0 Center for Software Technology Sander Mak, Thomas van Noort
  • 50. Recursion Pattern Analysis and Feedback > Related Work Dr. Haskell A tool to detect common patterns in Haskell code: Example definition f n x = take n (repeat x) Suggestion f n x = replicate n x Implemented by normalizing code and matching hard-coded patterns: Defined pattern use replicate n x = take n (repeat x) Center for Software Technology Sander Mak, Thomas van Noort
  • 51. Recursion Pattern Analysis and Feedback > Related Work Dr. Haskell (2) Developed by Neil Mitchell at the University of York Implemented using Yhc Only recognizes patterns in function application... ... and lacks recognizing patterns in function definitions Only based on syntactic restrictions... ... and lacks semantic restrictions Only points to source location which matches a pattern... ... instead of giving a suggestion Not really suited for recognizing recursion patterns in general Center for Software Technology Sander Mak, Thomas van Noort
  • 52. Recursion Pattern Analysis and Feedback > Conclusion General observations The current implementation is restricted to: Expressions without shadowed identifiers Recognizing (some) foldr patterns on lists, reusability of certain components has yet to be proven Expressions with a fixλcase construct at top-level Simplifying just some lambda abstractions Always just returning a more ’elegant’ solution, although this is not always the case Suggested definition for weird λl1 → foldr (λ xs → λl3 → append l3 (xs l3 )) (λl3 → l1 ) The implementation is not complete at all, but believed to be sound... Center for Software Technology Sander Mak, Thomas van Noort
  • 53. Recursion Pattern Analysis and Feedback > Conclusion Future work First thing to do, try to recognize other recursion patterns: Is is easy to implement recognizing other recursion patterns? What parts can be reused? Is there a general structure which can be abstracted over? Keeping quality of feedback in mind of course... Which suggestions are shown? Reducing the complexity of the suggestions by simplifying Center for Software Technology Sander Mak, Thomas van Noort
  • 54. Recursion Pattern Analysis and Feedback > Conclusion Concluding remarks No supporting theory available, so our approach consists of Trial-and-error Use of unit tests Lots of hard thinking... Translation to mature language Requires normalisation of expressions to be analyzed Normalisation should not interfere with feedback Giving feedback requires pointing to source location Lambda simplification improves the quality of feedback Current feedback would already be useful for 1st -year FP students Center for Software Technology Sander Mak, Thomas van Noort
  • 55. Recursion Pattern Analysis and Feedback > Conclusion Discussion Should prelude functions (e.g. const, flip and id) be used in our feedback? Center for Software Technology Sander Mak, Thomas van Noort
  • 56. Recursion Pattern Analysis and Feedback > Conclusion Discussion Should prelude functions (e.g. const, flip and id) be used in our feedback? What determines the complexity of a suggestion? Center for Software Technology Sander Mak, Thomas van Noort
  • 57. Recursion Pattern Analysis and Feedback > Conclusion Discussion Should prelude functions (e.g. const, flip and id) be used in our feedback? What determines the complexity of a suggestion? Would you expand detection to arbitrary datatypes (width) or expand by adding new patterns over the List-datatype (depth)? Center for Software Technology Sander Mak, Thomas van Noort
  • 58. Recursion Pattern Analysis and Feedback > Conclusion Discussion Should prelude functions (e.g. const, flip and id) be used in our feedback? What determines the complexity of a suggestion? Would you expand detection to arbitrary datatypes (width) or expand by adding new patterns over the List-datatype (depth)? Which patterns would be useful to detect? Center for Software Technology Sander Mak, Thomas van Noort