In Haskell I try to call the following two newtypes
that have I have declared.
Why does this work:
newtype CharList = CharList { get2CharList :: [Char] } deriving (Eq, Show)
ghci> CharList "some"
CharList {get2CharList = "some"}
When this does not work:
newtype Pair a b = Pair { createPair :: (a, b) } deriving (Eq, Show)
ghci> Pair 2 4
<interactive>:13:1: error:
* Couldn't match expected type: t0 -> t
with actual type: Pair a0 b0
* The function `Pair' is applied to two value arguments,
but its type `(a0, b0) -> Pair a0 b0' has only one
In the expression: Pair 2 4
In an equation for `it': it = Pair 2 4
* Relevant bindings include it :: t (bound at <interactive>:13:1)
Does it require a Monad to work as seen here: The Writer monad and its type declaration
And will I necessarily then have to constraint the type when calling the newtype
Furthermore, how can I go about it if I want a newtype
to take even more arguments such as 3?