Is there a ($) equivalent for types in Haskell?
If I have a type with parameters
data myType a b c = ...
It would be nice to apply a monad like so :
f :: input -> errorMonad $ myType a b c
{- throws error:
Not in scope: type constructor or class ‘$’. -}
I can get the same effect with
f :: input -> errorMonad (myType a b c)
but is not as clear IMO.
(:==) is not a valid symbol for a function or variable identifier in Haskell.
in goes along with let to name one or more local expressions in a pure function.
The Nil constructor is an empty list. It contains no objects. So any time you're using the [] expression, you're actually using Nil . Then the second constructor concatenates a single element with another list. The type of the element and the list must match up obviously.
return is actually just a simple function in Haskell. It does not return something. It wraps a value into a monad. Looks like return is an overloaded function.
A possible solution is to define your own type operator $
:
{-# LANGUAGE TypeOperators, PolyKinds #-}
type ($) a = a
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