Resolving Ambiguous Types in Haskell by Checking Uniqueness of Type Variable Assignments under Type Class Constraints

The type class mechanism, which introduces ad-hoc polymorphism into programming languages, is commonly used to realize overloading. However, this forces programmers to write many type annotations in their programs to resolve ambiguous types. Haskell's type defaulting rules reduce requirements f...

Ausführliche Beschreibung

Gespeichert in:
Bibliographische Detailangaben
Veröffentlicht in:Journal of Information Processing 2019, Vol.27, pp.87-94
Hauptverfasser: Kono, Yuya, Kawabata, Hideyuki, Hironaka, Tetsuo
Format: Artikel
Sprache:eng
Schlagworte:
Online-Zugang:Volltext
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
container_end_page 94
container_issue
container_start_page 87
container_title Journal of Information Processing
container_volume 27
creator Kono, Yuya
Kawabata, Hideyuki
Hironaka, Tetsuo
description The type class mechanism, which introduces ad-hoc polymorphism into programming languages, is commonly used to realize overloading. However, this forces programmers to write many type annotations in their programs to resolve ambiguous types. Haskell's type defaulting rules reduce requirements for annotation. Furthermore, the widely used Glasgow Haskell Compiler (GHC) has an ExtendedDefaultRules (EDR) extension that facilitates interactive sessions so that the programmer avoids problems that frequently occur when using values like [] and Nothing. However, the GHC EDR extension sometimes replaces type variables with inappropriate types, so that, for example, the term show.read that is determined to have type String -> String under the GHC EDR extension does not exhibit any meaningful behavior because the function read in the term is considered to have type String -> (). We present a flexible way of resolving ambiguous types that alleviates this problem. Our proposed method does not depend on default types defined elsewhere but rather assigns a type to a type variable only when the candidate is unique. It works with any type and type class constraints. The type to be assigned is determined by scanning a list of existing type class instances that meet the type class constraints. This decision is lightweight as it is based on operations over sets without using algorithms that require backtracking. Our method is preferable to using the GHC EDR extension since it avoids the use of unnatural type variable assignments. In this paper, we describe the details of our method. We also discuss our prototype implementation that is based on the GHC plugins, and the feasibility of modifying GHC to incorporate our method.
doi_str_mv 10.2197/ipsjjip.27.87
format Article
fullrecord <record><control><sourceid>proquest_cross</sourceid><recordid>TN_cdi_proquest_journals_2226459435</recordid><sourceformat>XML</sourceformat><sourcesystem>PC</sourcesystem><sourcerecordid>2226459435</sourcerecordid><originalsourceid>FETCH-LOGICAL-c3557-8e7783f8bf026ff79e97aed7e91ec982102a7e2fb580e6fd253050230c0df433</originalsourceid><addsrcrecordid>eNpN0FFLwzAQB_AgCs7po-8BnzvTdG3SN0dRJwwEmb6GtL1s6bq05lph397OjuFTDv6_XC5HyH3IZjxMxaNtsapsO-NiJsUFmYRS8iBJYn75r74mN4gVY0nKYjYh_QdgU_9Yt6GLfW43fdMjXR9aQGodXWrcQV3T_ECzLRS7I_t09rsHB4i0MX-UfmlvdV4DXSDajduD65D2rgQ_5lmtB501Djuv7RDekiuja4S70zkl65fndbYMVu-vb9liFRRRHItAghAyMjI3jCfGiBRSoaEUkIZQpJKHjGsB3OSxZJCYksfR8CkesYKVZh5FU_Iwtm19M8yMnaqa3rvhRcU5T-ZxOo_iQQWjKnyD6MGo1tu99gcVMnVcrDotVnGhpBj80-gr7PQGzlr7zhY1_NdsvHKOiq32Clz0C2u7htg</addsrcrecordid><sourcetype>Aggregation Database</sourcetype><iscdi>true</iscdi><recordtype>article</recordtype><pqid>2226459435</pqid></control><display><type>article</type><title>Resolving Ambiguous Types in Haskell by Checking Uniqueness of Type Variable Assignments under Type Class Constraints</title><source>J-STAGE (Japan Science &amp; Technology Information Aggregator, Electronic) Freely Available Titles - Japanese</source><creator>Kono, Yuya ; Kawabata, Hideyuki ; Hironaka, Tetsuo</creator><creatorcontrib>Kono, Yuya ; Kawabata, Hideyuki ; Hironaka, Tetsuo</creatorcontrib><description>The type class mechanism, which introduces ad-hoc polymorphism into programming languages, is commonly used to realize overloading. However, this forces programmers to write many type annotations in their programs to resolve ambiguous types. Haskell's type defaulting rules reduce requirements for annotation. Furthermore, the widely used Glasgow Haskell Compiler (GHC) has an ExtendedDefaultRules (EDR) extension that facilitates interactive sessions so that the programmer avoids problems that frequently occur when using values like [] and Nothing. However, the GHC EDR extension sometimes replaces type variables with inappropriate types, so that, for example, the term show.read that is determined to have type String -&gt; String under the GHC EDR extension does not exhibit any meaningful behavior because the function read in the term is considered to have type String -&gt; (). We present a flexible way of resolving ambiguous types that alleviates this problem. Our proposed method does not depend on default types defined elsewhere but rather assigns a type to a type variable only when the candidate is unique. It works with any type and type class constraints. The type to be assigned is determined by scanning a list of existing type class instances that meet the type class constraints. This decision is lightweight as it is based on operations over sets without using algorithms that require backtracking. Our method is preferable to using the GHC EDR extension since it avoids the use of unnatural type variable assignments. In this paper, we describe the details of our method. We also discuss our prototype implementation that is based on the GHC plugins, and the feasibility of modifying GHC to incorporate our method.</description><identifier>ISSN: 1882-6652</identifier><identifier>EISSN: 1882-6652</identifier><identifier>DOI: 10.2197/ipsjjip.27.87</identifier><language>eng</language><publisher>Tokyo: Information Processing Society of Japan</publisher><subject>Algorithms ; Annotations ; Haskell ; Overloading ; Polymorphism ; Programming languages ; type ambiguity ; type class ; type defaulting</subject><ispartof>Journal of Information Processing, 2019, Vol.27, pp.87-94</ispartof><rights>2019 by the Information Processing Society of Japan</rights><rights>Copyright Japan Science and Technology Agency 2019</rights><oa>free_for_read</oa><woscitedreferencessubscribed>false</woscitedreferencessubscribed><cites>FETCH-LOGICAL-c3557-8e7783f8bf026ff79e97aed7e91ec982102a7e2fb580e6fd253050230c0df433</cites></display><links><openurl>$$Topenurl_article</openurl><openurlfulltext>$$Topenurlfull_article</openurlfulltext><thumbnail>$$Tsyndetics_thumb_exl</thumbnail><link.rule.ids>314,780,784,1883,4024,27923,27924,27925</link.rule.ids></links><search><creatorcontrib>Kono, Yuya</creatorcontrib><creatorcontrib>Kawabata, Hideyuki</creatorcontrib><creatorcontrib>Hironaka, Tetsuo</creatorcontrib><title>Resolving Ambiguous Types in Haskell by Checking Uniqueness of Type Variable Assignments under Type Class Constraints</title><title>Journal of Information Processing</title><addtitle>Journal of Information Processing</addtitle><description>The type class mechanism, which introduces ad-hoc polymorphism into programming languages, is commonly used to realize overloading. However, this forces programmers to write many type annotations in their programs to resolve ambiguous types. Haskell's type defaulting rules reduce requirements for annotation. Furthermore, the widely used Glasgow Haskell Compiler (GHC) has an ExtendedDefaultRules (EDR) extension that facilitates interactive sessions so that the programmer avoids problems that frequently occur when using values like [] and Nothing. However, the GHC EDR extension sometimes replaces type variables with inappropriate types, so that, for example, the term show.read that is determined to have type String -&gt; String under the GHC EDR extension does not exhibit any meaningful behavior because the function read in the term is considered to have type String -&gt; (). We present a flexible way of resolving ambiguous types that alleviates this problem. Our proposed method does not depend on default types defined elsewhere but rather assigns a type to a type variable only when the candidate is unique. It works with any type and type class constraints. The type to be assigned is determined by scanning a list of existing type class instances that meet the type class constraints. This decision is lightweight as it is based on operations over sets without using algorithms that require backtracking. Our method is preferable to using the GHC EDR extension since it avoids the use of unnatural type variable assignments. In this paper, we describe the details of our method. We also discuss our prototype implementation that is based on the GHC plugins, and the feasibility of modifying GHC to incorporate our method.</description><subject>Algorithms</subject><subject>Annotations</subject><subject>Haskell</subject><subject>Overloading</subject><subject>Polymorphism</subject><subject>Programming languages</subject><subject>type ambiguity</subject><subject>type class</subject><subject>type defaulting</subject><issn>1882-6652</issn><issn>1882-6652</issn><fulltext>true</fulltext><rsrctype>article</rsrctype><creationdate>2019</creationdate><recordtype>article</recordtype><recordid>eNpN0FFLwzAQB_AgCs7po-8BnzvTdG3SN0dRJwwEmb6GtL1s6bq05lph397OjuFTDv6_XC5HyH3IZjxMxaNtsapsO-NiJsUFmYRS8iBJYn75r74mN4gVY0nKYjYh_QdgU_9Yt6GLfW43fdMjXR9aQGodXWrcQV3T_ECzLRS7I_t09rsHB4i0MX-UfmlvdV4DXSDajduD65D2rgQ_5lmtB501Djuv7RDekiuja4S70zkl65fndbYMVu-vb9liFRRRHItAghAyMjI3jCfGiBRSoaEUkIZQpJKHjGsB3OSxZJCYksfR8CkesYKVZh5FU_Iwtm19M8yMnaqa3rvhRcU5T-ZxOo_iQQWjKnyD6MGo1tu99gcVMnVcrDotVnGhpBj80-gr7PQGzlr7zhY1_NdsvHKOiq32Clz0C2u7htg</recordid><startdate>2019</startdate><enddate>2019</enddate><creator>Kono, Yuya</creator><creator>Kawabata, Hideyuki</creator><creator>Hironaka, Tetsuo</creator><general>Information Processing Society of Japan</general><general>Japan Science and Technology Agency</general><scope>AAYXX</scope><scope>CITATION</scope><scope>7SC</scope><scope>8FD</scope><scope>JQ2</scope><scope>L7M</scope><scope>L~C</scope><scope>L~D</scope></search><sort><creationdate>2019</creationdate><title>Resolving Ambiguous Types in Haskell by Checking Uniqueness of Type Variable Assignments under Type Class Constraints</title><author>Kono, Yuya ; Kawabata, Hideyuki ; Hironaka, Tetsuo</author></sort><facets><frbrtype>5</frbrtype><frbrgroupid>cdi_FETCH-LOGICAL-c3557-8e7783f8bf026ff79e97aed7e91ec982102a7e2fb580e6fd253050230c0df433</frbrgroupid><rsrctype>articles</rsrctype><prefilter>articles</prefilter><language>eng</language><creationdate>2019</creationdate><topic>Algorithms</topic><topic>Annotations</topic><topic>Haskell</topic><topic>Overloading</topic><topic>Polymorphism</topic><topic>Programming languages</topic><topic>type ambiguity</topic><topic>type class</topic><topic>type defaulting</topic><toplevel>online_resources</toplevel><creatorcontrib>Kono, Yuya</creatorcontrib><creatorcontrib>Kawabata, Hideyuki</creatorcontrib><creatorcontrib>Hironaka, Tetsuo</creatorcontrib><collection>CrossRef</collection><collection>Computer and Information Systems Abstracts</collection><collection>Technology Research Database</collection><collection>ProQuest Computer Science Collection</collection><collection>Advanced Technologies Database with Aerospace</collection><collection>Computer and Information Systems Abstracts – Academic</collection><collection>Computer and Information Systems Abstracts Professional</collection><jtitle>Journal of Information Processing</jtitle></facets><delivery><delcategory>Remote Search Resource</delcategory><fulltext>fulltext</fulltext></delivery><addata><au>Kono, Yuya</au><au>Kawabata, Hideyuki</au><au>Hironaka, Tetsuo</au><format>journal</format><genre>article</genre><ristype>JOUR</ristype><atitle>Resolving Ambiguous Types in Haskell by Checking Uniqueness of Type Variable Assignments under Type Class Constraints</atitle><jtitle>Journal of Information Processing</jtitle><addtitle>Journal of Information Processing</addtitle><date>2019</date><risdate>2019</risdate><volume>27</volume><spage>87</spage><epage>94</epage><pages>87-94</pages><issn>1882-6652</issn><eissn>1882-6652</eissn><abstract>The type class mechanism, which introduces ad-hoc polymorphism into programming languages, is commonly used to realize overloading. However, this forces programmers to write many type annotations in their programs to resolve ambiguous types. Haskell's type defaulting rules reduce requirements for annotation. Furthermore, the widely used Glasgow Haskell Compiler (GHC) has an ExtendedDefaultRules (EDR) extension that facilitates interactive sessions so that the programmer avoids problems that frequently occur when using values like [] and Nothing. However, the GHC EDR extension sometimes replaces type variables with inappropriate types, so that, for example, the term show.read that is determined to have type String -&gt; String under the GHC EDR extension does not exhibit any meaningful behavior because the function read in the term is considered to have type String -&gt; (). We present a flexible way of resolving ambiguous types that alleviates this problem. Our proposed method does not depend on default types defined elsewhere but rather assigns a type to a type variable only when the candidate is unique. It works with any type and type class constraints. The type to be assigned is determined by scanning a list of existing type class instances that meet the type class constraints. This decision is lightweight as it is based on operations over sets without using algorithms that require backtracking. Our method is preferable to using the GHC EDR extension since it avoids the use of unnatural type variable assignments. In this paper, we describe the details of our method. We also discuss our prototype implementation that is based on the GHC plugins, and the feasibility of modifying GHC to incorporate our method.</abstract><cop>Tokyo</cop><pub>Information Processing Society of Japan</pub><doi>10.2197/ipsjjip.27.87</doi><tpages>8</tpages><oa>free_for_read</oa></addata></record>
fulltext fulltext
identifier ISSN: 1882-6652
ispartof Journal of Information Processing, 2019, Vol.27, pp.87-94
issn 1882-6652
1882-6652
language eng
recordid cdi_proquest_journals_2226459435
source J-STAGE (Japan Science & Technology Information Aggregator, Electronic) Freely Available Titles - Japanese
subjects Algorithms
Annotations
Haskell
Overloading
Polymorphism
Programming languages
type ambiguity
type class
type defaulting
title Resolving Ambiguous Types in Haskell by Checking Uniqueness of Type Variable Assignments under Type Class Constraints
url https://sfx.bib-bvb.de/sfx_tum?ctx_ver=Z39.88-2004&ctx_enc=info:ofi/enc:UTF-8&ctx_tim=2024-12-29T17%3A56%3A42IST&url_ver=Z39.88-2004&url_ctx_fmt=infofi/fmt:kev:mtx:ctx&rfr_id=info:sid/primo.exlibrisgroup.com:primo3-Article-proquest_cross&rft_val_fmt=info:ofi/fmt:kev:mtx:journal&rft.genre=article&rft.atitle=Resolving%20Ambiguous%20Types%20in%20Haskell%20by%20Checking%20Uniqueness%20of%20Type%20Variable%20Assignments%20under%20Type%20Class%20Constraints&rft.jtitle=Journal%20of%20Information%20Processing&rft.au=Kono,%20Yuya&rft.date=2019&rft.volume=27&rft.spage=87&rft.epage=94&rft.pages=87-94&rft.issn=1882-6652&rft.eissn=1882-6652&rft_id=info:doi/10.2197/ipsjjip.27.87&rft_dat=%3Cproquest_cross%3E2226459435%3C/proquest_cross%3E%3Curl%3E%3C/url%3E&disable_directlink=true&sfx.directlink=off&sfx.report_link=0&rft_id=info:oai/&rft_pqid=2226459435&rft_id=info:pmid/&rfr_iscdi=true