8 Matching Annotations
  1. Last 7 days
    1. he Haskell functions div and ^ are partial, meaning they can crash with a so-called imprecise exception (an exception that is not visible in the type, also sometimes called IO exceptions).

      partial functions

  2. Aug 2025
    1. We can use newtype whenever we define a datatype with a single constructor that has a single-value - intuitively, whenever we simply "wrap" an underlying type.

      Brug gerne newtype når vi bare skal "wrappe" en underliggende datatype (i det her tilfælde Double) med en anden datatype (som her er Q der er vores value constructor til højre for =)

    2. Note that we do not actually use the type parameter unit in the right hand side of the definition. It is a phantom type, that exists only at compile-time, in order to constrain how Qs can be used. When constructing a value of type Q, we can instantiate that unit with anything we want. For example

      Vigtig: forklaring af phantom type

    3. Specifically, we now define a type constructor Q for representing a quantity of some unit:

      Fra Learn You Haskell...: "Once again, it's very important to distinguish between the type constructor and the value constructor. When declaring a data type, the part before the = is the type constructor and the constructors after it (possibly separated by |'s) are value constructors." Så Q til vnstre er type constructoren med type parameteret unit, og Q til højre er valu constructor, som tager en Double

    4. ee how the fmap method turns an f a into an f b, intuitively changing the a values to b values. That means f by itself is not a type - it must be applied to a type, and hence is a type constructor.

      Faktisk rigtig fin forklaring for at forstå forskel på type og type constructor