Git Product home page Git Product logo

idris-dev's People

Contributors

adamse avatar bmsherman avatar danielwaterworth avatar david-christiansen avatar dpmulligan avatar edwinb avatar enolan avatar fieldstrength avatar hannesm avatar janbessai avatar japesinator avatar jeremy-w avatar jfdm avatar leifw avatar markuspf avatar melted avatar melvar avatar ozgurakgun avatar philipborgesen avatar puffnfresh avatar raichoo avatar ralith avatar reuleaux avatar reynir avatar shlevy avatar soimort avatar stepcut avatar tpsinnem avatar trillioneyes avatar ziman avatar

Watchers

 avatar  avatar  avatar  avatar

idris-dev's Issues

Copatterns desugaring bug

Given a tree:

corecord Tree : Type -> Type where
  value : Tree a -> a
  left  : Tree a -> Tree a
  right : Tree a -> Tree a

The following two should be equivalent:

total causal grow : (Nat, Nat) -> Tree(Nat, Nat)
grow (n, d) = MkTree (n, d) (grow (n, n + d)) (grow (n + d, d))

total causal grow' : (Nat, Nat) -> Tree (Nat, Nat)
&value grow' (n, d) = (n, d)
&left  grow' (n, d) = grow' (n, n + d)
&right grow' (n, d) = grow' (n + d, d)

The one without copatterns work, however the one with copatterns give the following error:

simple.idr:69:14:No type declaration for value

Either I am missing something or this is a bug.

Partial functions don't desugar to total functions with metavariables

Currently, the following only generates a clause for cycle (S n) m:

cycle : Nat -> Nat -> Stream' Nat
&hd cycle n m = n
&tl cycle (S n) m = cycle n m

Resulting in:

cycle : Nat -> Nat -> Stream' Nat
cycle (S n) m = MkStream' (S n) cycle n m

Perhaps two clauses should be generated, such that 'cycle' is desugared to:

cycle : Nat -> Nat -> Stream' Nat
cycle Z m = MkStream' Z ?cycletl
cycle (S n) m = MkStream' (S n) cycle n m

This may or may not be an issue.

Recognize copatterns without a preceding token

We currently make the user add a special token ('&' at the time of writing) in front of all left-hand side projections. It would be better if these were recognized automatically, without any guidance from the user.

Corecords: Projection Equivalence

Projections should be allowed to different as long as they are equivalent. The below example should be valid and should generate a constructor with one implicit:

corecord Stream : Type -> Type where
  head : Stream a -> a
  tail : Stream b -> Stream b

Branch: Corecords

Case analysis on types in corecords leads to a unification error

Trying to define the following program:

corecord Gedde : Type where
  han : Gedde -> Maybe Nat
  hun : Gedde -> (n : Nat) -> fisk Nat (Just n)
  stime : Gedde -> Gedde
  uvist : (john : Gedde) -> case han john of
                              Just n => Vect n (Maybe Nat)
                              Nothing => Bool

I get the error:

When elaborating right hand side of x.Gedde.uvist:
Can't unify
        case block in MkGedde han hun stime han
with
        case block in MkGedde han
                              hun
                              (Delay (Force (Delay (Force stime))))
                              han

Specifically:
        Can't unify
                case block in MkGedde han hun stime han
        with
                case block in MkGedde han
                                      hun
                                      (Delay (Force (Delay (Force stime))))
                                      han

However, an equivalent record definition only issues warnings:

record A : Type where
  MkA : (han : Maybe Nat) -> (hun : (n : Nat) -> 
            fisk Nat (Just n)) -> (stime : A) -> 
            (uvist : case han of
                           Just n => Vect n (Maybe Nat)
                           Nothing => Bool) -> 
            A

I believe case analysis in types in corecords should be possible.

Equivalent clauses should be reduced to one clause

If we have two or more equivalent clauses, only one clause should be produced by the desugaring step.
Example:

&hd f Z = rhs1
&hd f (S n) = rhs2
&tl f Z = rhs3
&tl f (S n) = rhs4

Currently produces:

f Z = mk rhs1 rhs3
f (S n) = mk rhs2 rhs4
f Z = mk rhs1 rhs3
f (S n) = mk rhs2 rhs4

While it should only produce:

f Z = mk rhs1 rhs3
f (S n) = mk rhs2 rhs4

Corecords: Setter Generation

Setter generation does not work for corecords. It generates a warning like:

corecords.idr:3:10:Warning - can't generate setter for Corecords.Stream'.hd (tydecl Corecords.Stream'.set_hd : {a : _} -> ({Corecords.Stream'.hd_out0} : a) -> ({rec0} : Corecords.Stream' a) -> Corecords.Stream' a)

Branch: Corecords

Corecords: Inference in type constructor does not work properly.

The following results in an error when elaborating projection functions:

corecord BisimStream' : Stream' a -> Stream' a -> Type where
  phd : BisimStream' s s' -> (hd s) = (hd s')
  ptl : BisimStream' s s' -> BisimStream' (tl s) (tl s')

Explicitly adding the type to the type constructor solves this:

corecord BisimStream' : (a : Type) -> Stream' a -> Stream' a -> Type where
  phd : BisimStream' a s s' -> (hd s) = (hd s')
  ptl : BisimStream' a s s' -> BisimStream' a (tl s) (tl s')

This problem also exists for records and is as such not a problem with our implementation.

Branch: Corecords

Implement new desugaring mechanism for copatterns

Here are some examples of how we want to desugar copatterns in the future, in order to make where-blocks work properly (and perhaps also withs).

zeros : Stream Nat
head zeros = Z
tail zeros = zeros

-- Desugared version
zeros : Stream Nat
zeros = MkStream head_ tail_
  where
    head_ : Nat
    head_ = Z

    tail_ : Stream Nat
    tail_ = zeros
cycle : Nat -> Nat -> Stream Nat
head cycle n m = n
tail cycle Z m = cycle m m 
tail cycle (S n) m = cycle n m

-- Desugared version
cycle : Nat -> Nat -> Stream Nat
cycle n m = MkStream (head_ n m) (tail_ n m)
  where
   head_ : Nat -> Nat -> Nat
   head_ n m = n

   tail_ : Nat -> Nat -> Stream Nat
   tail_ Z m = cycle m m
   tail_ (S n) m = cycle n m
corecord Foo : Type where
  bar : Foo -> Bool
  baz : (f : Foo) -> if (bar f) then Nat else Bool

foo : Foo
bar foo = True
baz foo = S Z

-- Desugared version
foo : Foo
foo = MkFoo bar_ baz_
  where
   bar_ : Bool
   bar_ = True

   baz_ : if bar_ then Nat else Bool
   baz_ = S Z

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.