I am a beginner with Elm and as a former Haskell programmer I wonder, if there is a way like in Haskell to type in the interpreter/REPL:
:i number
So I know that this does not work in Elm, but is there something equivalent to Haskell's:
:i Num
I want to get detailed information about a type class and all its instances.
Furthermore in the Haskell documentation there is information available about the type hierarchy of the basic Haskell classes:
https://www.haskell.org/onlinereport/basic.html
Is something like that available for Elm too?
Thanks in advance.
Elm doesn't have type classes, so it's not really applicable for it to show information about them, as GHCi's :i
does. The scope of Elm's built in types, like strings, numbers, and bools, is fairly obvious.
Elm's type hierarchy is pretty simple. There are three built-in type-class-like type variables. Unlike Haskell which puts constraints before a =>
, just use these type variables directly. Fair warning: Haskell users typically find Elm's type system limiting. (The tool ecosystem is also less advanced, by virtue of Haskell's 20+ year head start.)
number
is either an Int
or Float
. A number literal without a decimal point is a number
. Arithmetic other than division can be done to either number type.comparable
can be a number, character, string, or recursively a list or tuple of comparables. Comparables support <
, >=
, and similar.appendable
can be a string, text (i.e. with typesetting information), or a list (containing any type). Appendables can be appended with (++)
.Eq
type. Attempting to equate functions or signals causes a runtime error.The practical implications of this are:
Signal.dropRepeats
on a signal of functions, or containers of functions, it can crash.comparable
. Same goes for set elements.appendable1
or similar.If you want Haskell in the browser, try PureScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With