{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeFamilies #-}
module Grisette.Internal.Core.Data.Class.Function
(
Function (..),
Apply (..),
)
where
class Function f arg ret | f -> arg ret where
(#) :: f -> arg -> ret
infixl 9 #
instance Function (a -> b) a b where
a -> b
f # :: (a -> b) -> a -> b
# a
a = a -> b
f a
a
class Apply uf where
type FunType uf
apply :: uf -> FunType uf
instance Apply Integer where
type FunType Integer = Integer
apply :: Integer -> FunType Integer
apply = Integer -> Integer
Integer -> FunType Integer
forall a. a -> a
id
instance Apply Bool where
type FunType Bool = Bool
apply :: Bool -> FunType Bool
apply = Bool -> Bool
Bool -> FunType Bool
forall a. a -> a
id
instance (Apply b) => Apply (a -> b) where
type FunType (a -> b) = a -> FunType b
apply :: (a -> b) -> FunType (a -> b)
apply a -> b
f a
a = b -> FunType b
forall uf. Apply uf => uf -> FunType uf
apply (a -> b
f a
a)