Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We have types and we have values. A Type is a set of (infinite) values. <code>String</code> is a type and all the possible string values are part of the <code>String</code> set. Now, the most important distinction about types and values is this - Types are about compile time and Values are available at runtime. </p> <p>If we look at you first example which talks about a new <strong>type</strong> which is subtype (or subset) of Int type such that "the <strong>value</strong> of the Int can't be zero", which means you want to define a type which put some restrictions on a value BUT types are compile time and values are runtime things - a compile time thing can't restrict a runtime thing because the runtime thing is not there yet for compile time thing to consume.</p> <p>Similarly the handle value is a runtime thing and only at runtime you can know if it is closed or not and for that you have functions to check whether the handle is closed or not. IO is all about runtime and you can't use a type system to get free of IOErrors.</p> <p>For modeling runtime failures you can use data types like <code>Maybe</code> or <code>Either</code> to indicate that the function may not be able to do what is was supposed to do and as these data types implements functors, moands and other computations patterns you can easily compose them.</p> <p>A type system is more of a structuring/design tool which make things more explicit and clear and makes you think more about your design but it can't do what <strong>functions</strong> are supposed to do. </p> <p>The film is : Typed Lambda calculus. Lambda in lead role, Typed in supporting role :) </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload