import Data.Char (Char)
import Data.Either (Either(..))
import Data.Eq (Eq)
+import Data.Int (Int)
import Data.Kind (Type)
import Data.Maybe (Maybe(..), fromJust)
import Data.Proxy (Proxy(..))
import Data.Semigroup (Semigroup)
+import Data.String (String)
import GHC.Generics (Generic)
+import Numeric.Natural (Natural)
import qualified Control.Category as Cat
import qualified Data.Function as Fun
import qualified Data.Tuple as Tuple
FromDerived (Constantable c) repr =>
c -> repr c
-bool :: Constantable Bool repr => Bool -> repr Bool
-bool = constant @Bool
-char :: Constantable Char repr => Char -> repr Char
-char = constant @Char
-unit :: Constantable () repr => repr ()
-unit = constant @() ()
-
-- * Class 'Eitherable'
class Eitherable repr where
left :: repr (l -> Either l r)
Eq a => repr (a -> a -> Bool)
infix 4 `equal`, ==
-(==) :: (Abstractable repr, Equalable repr, Eq a) => repr (a -> a -> Bool)
-(==) = lam (\x -> lam (\y -> equal .@ x .@ y))
+(==) ::
+ Abstractable repr => Equalable repr => Eq a =>
+ repr a -> repr a -> repr Bool
+(==) x y = equal .@ x .@ y
-- * Class 'IfThenElseable'
class IfThenElseable repr where
FromDerived3 IfThenElseable repr =>
repr Bool -> repr a -> repr a -> repr a
+-- * Class 'Inferable'
+class Inferable a repr where
+ infer :: repr a
+ default infer :: FromDerived (Inferable a) repr => repr a
+ infer = liftDerived infer
+
+unit :: Inferable () repr => repr ()
+unit = infer
+bool :: Inferable Bool repr => repr Bool
+bool = infer
+char :: Inferable Char repr => repr Char
+char = infer
+int :: Inferable Int repr => repr Int
+int = infer
+natural :: Inferable Natural repr => repr Natural
+natural = infer
+string :: Inferable String repr => repr String
+string = infer
+
-- * Class 'Listable'
class Listable repr where
cons :: repr (a -> [a] -> [a])