Pattern matching has become a very important feature in functional programming. Many languages in this category heavily depend on it, especially when it comes to the definition of functions. In this case, pattern matching acts like a dispatcher that executes the right portion of code depending on the structure of the arguments. Coding with this pattern-action paradigm leads to less error-prone programs. But how powerful can patterns be, so that always more logic is expressed with them rather than in the code that will be executed? Many languages try to make patterns more expressive and powerful. One example is F# that makes the pattern system extensible with its active patterns. In this thesis, I analyze pattern matching in Haskell, a purely functional programming language, finding its strengths and weaknesses. Once identified those, I describe an extension that takes advantage of the power of its pattern matching and tries to overcome some of its limits. This extension is defined as a superset of the Haskell syntax, this means that every program written in the extended form can be compiled down to Haskell.

Il Pattern matching è diventato molto importante nella programmazione funzionale. Molti linguaggi in questa categoria ne dipendono pesantemente, soprattutto per quanto riguarda la definizione di funzioni. In questo caso il pattern matching assume il ruolo di dispatcher ed esegue la giusta porzione di codice in base alla struttura dei parametri. Programmare con questo paradigma pattern-action, porta ad ottenere programmi meno soggetti a errori. Ma quanto potenti possono essere i pattern in modo che sempre più logica sia espressa al loro interno piuttosto che nel codice che verrà eseguito? Molti linguaggi cercano di rendere i pattern più espressivi e potenti. Ne è un esempio F# che rende i pattern estensibili con gli active patterns. In questa tesi analizzo il pattern matching di Haskell, un linguaggio puramente funzionale, cercando i suoi punti di forza e debolezza. Una volta identificati, descrivo un'estensione che sfrutta la potenza del suo pattern matching, e ne cerca di superare alcuni limiti. L'estensione è definita come un superset della sintassi di Haskell, in questo modo ogni programma scritto nella forma estesa può essere compilato in Haskell.

Toward a more expressive pattern matching in Haskell

SERVADEI, GIACOMO
2016/2017

Abstract

Pattern matching has become a very important feature in functional programming. Many languages in this category heavily depend on it, especially when it comes to the definition of functions. In this case, pattern matching acts like a dispatcher that executes the right portion of code depending on the structure of the arguments. Coding with this pattern-action paradigm leads to less error-prone programs. But how powerful can patterns be, so that always more logic is expressed with them rather than in the code that will be executed? Many languages try to make patterns more expressive and powerful. One example is F# that makes the pattern system extensible with its active patterns. In this thesis, I analyze pattern matching in Haskell, a purely functional programming language, finding its strengths and weaknesses. Once identified those, I describe an extension that takes advantage of the power of its pattern matching and tries to overcome some of its limits. This extension is defined as a superset of the Haskell syntax, this means that every program written in the extended form can be compiled down to Haskell.
ING - Scuola di Ingegneria Industriale e dell'Informazione
19-apr-2018
2016/2017
Il Pattern matching è diventato molto importante nella programmazione funzionale. Molti linguaggi in questa categoria ne dipendono pesantemente, soprattutto per quanto riguarda la definizione di funzioni. In questo caso il pattern matching assume il ruolo di dispatcher ed esegue la giusta porzione di codice in base alla struttura dei parametri. Programmare con questo paradigma pattern-action, porta ad ottenere programmi meno soggetti a errori. Ma quanto potenti possono essere i pattern in modo che sempre più logica sia espressa al loro interno piuttosto che nel codice che verrà eseguito? Molti linguaggi cercano di rendere i pattern più espressivi e potenti. Ne è un esempio F# che rende i pattern estensibili con gli active patterns. In questa tesi analizzo il pattern matching di Haskell, un linguaggio puramente funzionale, cercando i suoi punti di forza e debolezza. Una volta identificati, descrivo un'estensione che sfrutta la potenza del suo pattern matching, e ne cerca di superare alcuni limiti. L'estensione è definita come un superset della sintassi di Haskell, in questo modo ogni programma scritto nella forma estesa può essere compilato in Haskell.
Tesi di laurea Magistrale
File allegati
File Dimensione Formato  
Tesi.pdf

accessibile in internet per tutti

Descrizione: Thesis text
Dimensione 341.98 kB
Formato Adobe PDF
341.98 kB Adobe PDF Visualizza/Apri

I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/10589/140161