Skip to content

Identity optimisation not kicking in #3782

@ohad

Description

@ohad

Steps to Reproduce

Load this:

public export
data Tree : Type where
  Leaf : Tree
  Node : Tree -> Tree -> Tree

namespace Foo
  public export
  data Path : Type where
    Nil : Path
    ConsL : Path -> Path
    ConsR : Path -> Path


namespace Bar
  public export
  data PathIn : Tree -> Type where
    Nil : PathIn Leaf
    ConsL : PathIn lft -> PathIn (Node lft rgt)
    ConsR : PathIn rgt -> PathIn (Node lft rgt)

-- Expecting identity transformation to kick in
f : PathIn tree -> Path
f [] = []
f (ConsL t) = ConsL (f t)
f (ConsR t) = ConsR (f t)

Then at the REPL:

> :di f

Expected Behavior

Main.f
...
Compiled: \ {arg:1} => {arg:1}

Observed Behavior

Main.f
...
Compiled: \ {arg:1} => case {arg:1} of
  { Main.Bar.Nil {tag = 0} => Main.Foo.Nil {tag = 0}
  ; Main.Bar.ConsL {tag = 1} {e:2} => Main.Foo.ConsL {tag = 1} (Main.f {e:2})
  ; Main.Bar.ConsR {tag = 2} {e:5} => Main.Foo.ConsR {tag = 2} (Main.f {e:5})
  }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions