Skip to content

Commit

Permalink
Add advanced type class issue
Browse files Browse the repository at this point in the history
Using something like associated types.

I'm not sure if exactly this program should be allowed but it would be
nice if we could achieve something like this.
  • Loading branch information
ollef committed Nov 1, 2017
1 parent b4968e8 commit 87c7788
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions issues/type-checking/Container.vix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
the : (a : Type) -> a -> a
the _ a = a

class ContainerElement c where
Element : forall proxy. proxy c -> Type

class Container c where
map
: ContainerElement c
=> (Element (the (Maybe c) Nothing) -> Element (the (Maybe c) Nothing))
-> c
-> c

type Maybe a = Nothing | Just a

instance forall a. ContainerElement (Maybe a) where
Element : forall a proxy. proxy (Maybe a) -> Type
Element @a _ = a

instance forall a. Container (Maybe a) where
map f Nothing = Nothing
map f (Just a) = Just (f a)

0 comments on commit 87c7788

Please sign in to comment.