idris - Data Type Encompassing Two Sum Types? -


given these 2 sum types:

data foo = int | b string data bar = c int | d string 

i'd define function returns either (foo or bar) string.

so, attempted make:

data higher = foo | bar

but failed compile:

*adt> :r type checking ./adt.idr adt.idr:3:6:main.foo defined adt.idr:4:6:main.bar defined 

how can create higher data type, consists of foo or bar?

yes can indeed!

data foo = int | b string data bar = c int | d string  data higher : type     injfoo : foo -> higher     injbar : bar -> higher 

now can injfoo (b "hello") or injbar (c 5).


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -