Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • C cduce
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 18
    • Issues 18
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • cduce
  • cduce
  • Issues
  • #2

Closed
Open
Created Mar 22, 2016 by Kim Nguyễn@knOwner

Determine the types of variables in matched expressions

fun (x : Int|Bool , y : Int | Bool) : Int | Bool = 
  match (x,y) with 
   | (Int,Bool) -> if y then x+3 else x +2
   | _ -> x;;

does not type. In order to have it working we have to redefine the pattern as follows

fun (x : Int|Bool , y : Int | Bool) : Int | Bool = 
  match (x,y) with 
   | (Int,Bool)&(x,y) -> if y then x+3 else x +2
   | _ -> x;;

Idea ... in order to refine the type of variables occuring in the MATCHED expression, then whenever this expression is ALSO A PATTERN rewrite it as follows:

match p with p1 -> e1 | ... | pn-> en

into

match p with p&p1 -> e1 | ... | p&pn-> en

Unfortunately this does not work when p and pi have a variable in common. We must find a smarter solution.

Edited Oct 08, 2021 by Kim Nguyễn
Assignee
Assign to
Time tracking