{-# LANGUAGE TypeFamilies #-}
module Futhark.IR.Prop.Patterns
(
paramIdent,
paramType,
paramDeclType,
patElemIdent,
patElemType,
setPatElemDec,
patIdents,
patNames,
patTypes,
patSize,
basicPat,
)
where
import Futhark.IR.Prop.Types (DeclTyped (..), Typed (..))
import Futhark.IR.Syntax
paramType :: Typed dec => Param dec -> Type
paramType :: forall dec. Typed dec => Param dec -> Type
paramType = forall t. Typed t => t -> Type
typeOf
paramDeclType :: DeclTyped dec => Param dec -> DeclType
paramDeclType :: forall dec. DeclTyped dec => Param dec -> DeclType
paramDeclType = forall t. DeclTyped t => t -> DeclType
declTypeOf
paramIdent :: Typed dec => Param dec -> Ident
paramIdent :: forall dec. Typed dec => Param dec -> Ident
paramIdent Param dec
param = VName -> Type -> Ident
Ident (forall dec. Param dec -> VName
paramName Param dec
param) (forall t. Typed t => t -> Type
typeOf Param dec
param)
patElemIdent :: Typed dec => PatElem dec -> Ident
patElemIdent :: forall dec. Typed dec => PatElem dec -> Ident
patElemIdent PatElem dec
pelem = VName -> Type -> Ident
Ident (forall dec. PatElem dec -> VName
patElemName PatElem dec
pelem) (forall t. Typed t => t -> Type
typeOf PatElem dec
pelem)
patElemType :: Typed dec => PatElem dec -> Type
patElemType :: forall dec. Typed dec => PatElem dec -> Type
patElemType = forall t. Typed t => t -> Type
typeOf
setPatElemDec :: PatElem oldattr -> newattr -> PatElem newattr
setPatElemDec :: forall oldattr newattr.
PatElem oldattr -> newattr -> PatElem newattr
setPatElemDec PatElem oldattr
pe newattr
x = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b. a -> b -> a
const newattr
x) PatElem oldattr
pe
patIdents :: Typed dec => Pat dec -> [Ident]
patIdents :: forall dec. Typed dec => Pat dec -> [Ident]
patIdents = forall a b. (a -> b) -> [a] -> [b]
map forall dec. Typed dec => PatElem dec -> Ident
patElemIdent forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall dec. Pat dec -> [PatElem dec]
patElems
patNames :: Pat dec -> [VName]
patNames :: forall dec. Pat dec -> [VName]
patNames = forall a b. (a -> b) -> [a] -> [b]
map forall dec. PatElem dec -> VName
patElemName forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall dec. Pat dec -> [PatElem dec]
patElems
patTypes :: Typed dec => Pat dec -> [Type]
patTypes :: forall dec. Typed dec => Pat dec -> [Type]
patTypes = forall a b. (a -> b) -> [a] -> [b]
map Ident -> Type
identType forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall dec. Typed dec => Pat dec -> [Ident]
patIdents
patSize :: Pat dec -> Int
patSize :: forall dec. Pat dec -> Int
patSize (Pat [PatElem dec]
xs) = forall (t :: * -> *) a. Foldable t => t a -> Int
length [PatElem dec]
xs
basicPat :: [Ident] -> Pat Type
basicPat :: [Ident] -> Pat Type
basicPat [Ident]
values =
forall dec. [PatElem dec] -> Pat dec
Pat forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map Ident -> PatElem Type
patElem [Ident]
values
where
patElem :: Ident -> PatElem Type
patElem (Ident VName
name Type
t) = forall dec. VName -> dec -> PatElem dec
PatElem VName
name Type
t