{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Safe #-}
-- | A simple representation with SOACs and nested parallelism.
module Futhark.IR.SOACS
       ( -- * The Lore definition
         SOACS
         -- * Syntax types
       , Body
       , Stm
       , Pattern
       , Exp
       , Lambda
       , FParam
       , LParam
       , RetType
       , PatElem
         -- * Module re-exports
       , module Futhark.IR.Prop
       , module Futhark.IR.Traversals
       , module Futhark.IR.Pretty
       , module Futhark.IR.Syntax
       , module Futhark.IR.SOACS.SOAC
       , AST.LambdaT(Lambda)
       , AST.BodyT(Body)
       , AST.PatternT(Pattern)
       , AST.PatElemT(PatElem)
       )
where

import qualified Futhark.IR.Syntax as AST
import Futhark.IR.Syntax
  hiding (Exp, Body, Stm,
          Pattern, Lambda, FParam, LParam, RetType, PatElem)
import Futhark.IR.SOACS.SOAC
import Futhark.IR.Prop
import Futhark.IR.Traversals
import Futhark.IR.Pretty
import Futhark.Binder
import Futhark.Construct
import qualified Futhark.TypeCheck as TypeCheck

-- This module could be written much nicer if Haskell had functors
-- like Standard ML.  Instead, we have to abuse the namespace/module
-- system.

-- | The lore for the basic representation.
data SOACS

instance Decorations SOACS where
  type Op SOACS = SOAC SOACS

instance ASTLore SOACS where
  expTypesFromPattern :: Pattern SOACS -> m [BranchType SOACS]
expTypesFromPattern = [ExtType] -> m [ExtType]
forall (m :: * -> *) a. Monad m => a -> m a
return ([ExtType] -> m [ExtType])
-> (PatternT Type -> [ExtType]) -> PatternT Type -> m [ExtType]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PatternT Type -> [ExtType]
forall dec. Typed dec => PatternT dec -> [ExtType]
expExtTypesFromPattern

type Exp = AST.Exp SOACS
type Body = AST.Body SOACS
type Stm = AST.Stm SOACS
type Pattern = AST.Pattern SOACS
type Lambda = AST.Lambda SOACS
type FParam = AST.FParam SOACS
type LParam = AST.LParam SOACS
type RetType = AST.RetType SOACS
type PatElem = AST.PatElem SOACS

instance TypeCheck.CheckableOp SOACS where
  checkOp :: OpWithAliases (Op SOACS) -> TypeM SOACS ()
checkOp = OpWithAliases (Op SOACS) -> TypeM SOACS ()
forall lore. Checkable lore => SOAC (Aliases lore) -> TypeM lore ()
typeCheckSOAC

instance TypeCheck.Checkable SOACS where

instance Bindable SOACS where
  mkBody :: Stms SOACS -> Result -> Body SOACS
mkBody = BodyDec SOACS -> Stms SOACS -> Result -> Body SOACS
forall lore. BodyDec lore -> Stms lore -> Result -> BodyT lore
AST.Body ()
  mkExpPat :: [Ident] -> [Ident] -> Exp SOACS -> Pattern SOACS
mkExpPat [Ident]
ctx [Ident]
val Exp SOACS
_ = [Ident] -> [Ident] -> PatternT Type
basicPattern [Ident]
ctx [Ident]
val
  mkExpDec :: Pattern SOACS -> Exp SOACS -> ExpDec SOACS
mkExpDec Pattern SOACS
_ Exp SOACS
_ = ()
  mkLetNames :: [VName] -> Exp SOACS -> m (Stm SOACS)
mkLetNames = [VName] -> Exp SOACS -> m (Stm SOACS)
forall lore (m :: * -> *).
(ExpDec lore ~ (), LetDec lore ~ Type, MonadFreshNames m,
 TypedOp (Op lore), HasScope lore m) =>
[VName] -> Exp lore -> m (Stm lore)
simpleMkLetNames

instance BinderOps SOACS where

instance PrettyLore SOACS where