{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Trustworthy #-}

module Futhark.Internalise.TypesValues
  ( -- * Internalising types
    internaliseReturnType,
    internaliseLambdaReturnType,
    internaliseEntryReturnType,
    internaliseType,
    internaliseParamTypes,
    internaliseLoopParamType,
    internalisePrimType,
    internalisedTypeSize,
    internaliseSumType,

    -- * Internalising values
    internalisePrimValue,
  )
where

import Control.Monad.Reader
import Control.Monad.State
import Data.List (delete, find, foldl')
import qualified Data.Map.Strict as M
import Data.Maybe
import Futhark.IR.SOACS as I
import Futhark.Internalise.Monad
import qualified Language.Futhark as E

internaliseUniqueness :: E.Uniqueness -> I.Uniqueness
internaliseUniqueness :: Uniqueness -> Uniqueness
internaliseUniqueness Uniqueness
E.Nonunique = Uniqueness
I.Nonunique
internaliseUniqueness Uniqueness
E.Unique = Uniqueness
I.Unique

type TypeState = Int

newtype InternaliseTypeM a
  = InternaliseTypeM (StateT TypeState InternaliseM a)
  deriving (a -> InternaliseTypeM b -> InternaliseTypeM a
(a -> b) -> InternaliseTypeM a -> InternaliseTypeM b
(forall a b. (a -> b) -> InternaliseTypeM a -> InternaliseTypeM b)
-> (forall a b. a -> InternaliseTypeM b -> InternaliseTypeM a)
-> Functor InternaliseTypeM
forall a b. a -> InternaliseTypeM b -> InternaliseTypeM a
forall a b. (a -> b) -> InternaliseTypeM a -> InternaliseTypeM b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> InternaliseTypeM b -> InternaliseTypeM a
$c<$ :: forall a b. a -> InternaliseTypeM b -> InternaliseTypeM a
fmap :: (a -> b) -> InternaliseTypeM a -> InternaliseTypeM b
$cfmap :: forall a b. (a -> b) -> InternaliseTypeM a -> InternaliseTypeM b
Functor, Functor InternaliseTypeM
a -> InternaliseTypeM a
Functor InternaliseTypeM
-> (forall a. a -> InternaliseTypeM a)
-> (forall a b.
    InternaliseTypeM (a -> b)
    -> InternaliseTypeM a -> InternaliseTypeM b)
-> (forall a b c.
    (a -> b -> c)
    -> InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM c)
-> (forall a b.
    InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b)
-> (forall a b.
    InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM a)
-> Applicative InternaliseTypeM
InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b
InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM a
InternaliseTypeM (a -> b)
-> InternaliseTypeM a -> InternaliseTypeM b
(a -> b -> c)
-> InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM c
forall a. a -> InternaliseTypeM a
forall a b.
InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM a
forall a b.
InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b
forall a b.
InternaliseTypeM (a -> b)
-> InternaliseTypeM a -> InternaliseTypeM b
forall a b c.
(a -> b -> c)
-> InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM a
$c<* :: forall a b.
InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM a
*> :: InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b
$c*> :: forall a b.
InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b
liftA2 :: (a -> b -> c)
-> InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM c
$cliftA2 :: forall a b c.
(a -> b -> c)
-> InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM c
<*> :: InternaliseTypeM (a -> b)
-> InternaliseTypeM a -> InternaliseTypeM b
$c<*> :: forall a b.
InternaliseTypeM (a -> b)
-> InternaliseTypeM a -> InternaliseTypeM b
pure :: a -> InternaliseTypeM a
$cpure :: forall a. a -> InternaliseTypeM a
$cp1Applicative :: Functor InternaliseTypeM
Applicative, Applicative InternaliseTypeM
a -> InternaliseTypeM a
Applicative InternaliseTypeM
-> (forall a b.
    InternaliseTypeM a
    -> (a -> InternaliseTypeM b) -> InternaliseTypeM b)
-> (forall a b.
    InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b)
-> (forall a. a -> InternaliseTypeM a)
-> Monad InternaliseTypeM
InternaliseTypeM a
-> (a -> InternaliseTypeM b) -> InternaliseTypeM b
InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b
forall a. a -> InternaliseTypeM a
forall a b.
InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b
forall a b.
InternaliseTypeM a
-> (a -> InternaliseTypeM b) -> InternaliseTypeM b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> InternaliseTypeM a
$creturn :: forall a. a -> InternaliseTypeM a
>> :: InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b
$c>> :: forall a b.
InternaliseTypeM a -> InternaliseTypeM b -> InternaliseTypeM b
>>= :: InternaliseTypeM a
-> (a -> InternaliseTypeM b) -> InternaliseTypeM b
$c>>= :: forall a b.
InternaliseTypeM a
-> (a -> InternaliseTypeM b) -> InternaliseTypeM b
$cp1Monad :: Applicative InternaliseTypeM
Monad, MonadState TypeState)

liftInternaliseM :: InternaliseM a -> InternaliseTypeM a
liftInternaliseM :: InternaliseM a -> InternaliseTypeM a
liftInternaliseM = StateT TypeState InternaliseM a -> InternaliseTypeM a
forall a. StateT TypeState InternaliseM a -> InternaliseTypeM a
InternaliseTypeM (StateT TypeState InternaliseM a -> InternaliseTypeM a)
-> (InternaliseM a -> StateT TypeState InternaliseM a)
-> InternaliseM a
-> InternaliseTypeM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InternaliseM a -> StateT TypeState InternaliseM a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift

runInternaliseTypeM ::
  InternaliseTypeM a ->
  InternaliseM a
runInternaliseTypeM :: InternaliseTypeM a -> InternaliseM a
runInternaliseTypeM (InternaliseTypeM StateT TypeState InternaliseM a
m) =
  StateT TypeState InternaliseM a -> TypeState -> InternaliseM a
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT StateT TypeState InternaliseM a
m TypeState
0

internaliseParamTypes ::
  [E.TypeBase (E.DimDecl VName) ()] ->
  InternaliseM [[I.TypeBase Shape Uniqueness]]
internaliseParamTypes :: [TypeBase (DimDecl VName) ()]
-> InternaliseM [[TypeBase Shape Uniqueness]]
internaliseParamTypes [TypeBase (DimDecl VName) ()]
ts =
  InternaliseTypeM [[TypeBase Shape Uniqueness]]
-> InternaliseM [[TypeBase Shape Uniqueness]]
forall a. InternaliseTypeM a -> InternaliseM a
runInternaliseTypeM (InternaliseTypeM [[TypeBase Shape Uniqueness]]
 -> InternaliseM [[TypeBase Shape Uniqueness]])
-> InternaliseTypeM [[TypeBase Shape Uniqueness]]
-> InternaliseM [[TypeBase Shape Uniqueness]]
forall a b. (a -> b) -> a -> b
$ (TypeBase (DimDecl VName) ()
 -> InternaliseTypeM [TypeBase Shape Uniqueness])
-> [TypeBase (DimDecl VName) ()]
-> InternaliseTypeM [[TypeBase Shape Uniqueness]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (([TypeBase ExtShape Uniqueness] -> [TypeBase Shape Uniqueness])
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
-> InternaliseTypeM [TypeBase Shape Uniqueness]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((TypeBase ExtShape Uniqueness -> TypeBase Shape Uniqueness)
-> [TypeBase ExtShape Uniqueness] -> [TypeBase Shape Uniqueness]
forall a b. (a -> b) -> [a] -> [b]
map TypeBase ExtShape Uniqueness -> TypeBase Shape Uniqueness
forall u. TypeBase ExtShape u -> TypeBase Shape u
onType) (InternaliseTypeM [TypeBase ExtShape Uniqueness]
 -> InternaliseTypeM [TypeBase Shape Uniqueness])
-> (TypeBase (DimDecl VName) ()
    -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase Shape Uniqueness]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
internaliseTypeM) [TypeBase (DimDecl VName) ()]
ts
  where
    onType :: TypeBase ExtShape u -> TypeBase Shape u
onType = TypeBase Shape u -> Maybe (TypeBase Shape u) -> TypeBase Shape u
forall a. a -> Maybe a -> a
fromMaybe TypeBase Shape u
forall a. a
bad (Maybe (TypeBase Shape u) -> TypeBase Shape u)
-> (TypeBase ExtShape u -> Maybe (TypeBase Shape u))
-> TypeBase ExtShape u
-> TypeBase Shape u
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeBase ExtShape u -> Maybe (TypeBase Shape u)
forall u. TypeBase ExtShape u -> Maybe (TypeBase Shape u)
hasStaticShape
    bad :: a
bad = [Char] -> a
forall a. HasCallStack => [Char] -> a
error ([Char] -> a) -> [Char] -> a
forall a b. (a -> b) -> a -> b
$ [Char]
"internaliseParamTypes: " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [TypeBase (DimDecl VName) ()] -> [Char]
forall a. Pretty a => a -> [Char]
pretty [TypeBase (DimDecl VName) ()]
ts

internaliseLoopParamType ::
  E.TypeBase (E.DimDecl VName) () ->
  InternaliseM [I.TypeBase Shape Uniqueness]
internaliseLoopParamType :: TypeBase (DimDecl VName) ()
-> InternaliseM [TypeBase Shape Uniqueness]
internaliseLoopParamType TypeBase (DimDecl VName) ()
et =
  [[TypeBase Shape Uniqueness]] -> [TypeBase Shape Uniqueness]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[TypeBase Shape Uniqueness]] -> [TypeBase Shape Uniqueness])
-> InternaliseM [[TypeBase Shape Uniqueness]]
-> InternaliseM [TypeBase Shape Uniqueness]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TypeBase (DimDecl VName) ()]
-> InternaliseM [[TypeBase Shape Uniqueness]]
internaliseParamTypes [TypeBase (DimDecl VName) ()
et]

internaliseReturnType ::
  E.TypeBase (E.DimDecl VName) () ->
  InternaliseM [I.TypeBase ExtShape Uniqueness]
internaliseReturnType :: TypeBase (DimDecl VName) ()
-> InternaliseM [TypeBase ExtShape Uniqueness]
internaliseReturnType TypeBase (DimDecl VName) ()
et =
  InternaliseTypeM [TypeBase ExtShape Uniqueness]
-> InternaliseM [TypeBase ExtShape Uniqueness]
forall a. InternaliseTypeM a -> InternaliseM a
runInternaliseTypeM (TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
internaliseTypeM TypeBase (DimDecl VName) ()
et)

internaliseLambdaReturnType ::
  E.TypeBase (E.DimDecl VName) () ->
  InternaliseM [I.TypeBase Shape NoUniqueness]
internaliseLambdaReturnType :: TypeBase (DimDecl VName) ()
-> InternaliseM [TypeBase Shape NoUniqueness]
internaliseLambdaReturnType = ([TypeBase Shape Uniqueness] -> [TypeBase Shape NoUniqueness])
-> InternaliseM [TypeBase Shape Uniqueness]
-> InternaliseM [TypeBase Shape NoUniqueness]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((TypeBase Shape Uniqueness -> TypeBase Shape NoUniqueness)
-> [TypeBase Shape Uniqueness] -> [TypeBase Shape NoUniqueness]
forall a b. (a -> b) -> [a] -> [b]
map TypeBase Shape Uniqueness -> TypeBase Shape NoUniqueness
forall shape.
TypeBase shape Uniqueness -> TypeBase shape NoUniqueness
fromDecl) (InternaliseM [TypeBase Shape Uniqueness]
 -> InternaliseM [TypeBase Shape NoUniqueness])
-> (TypeBase (DimDecl VName) ()
    -> InternaliseM [TypeBase Shape Uniqueness])
-> TypeBase (DimDecl VName) ()
-> InternaliseM [TypeBase Shape NoUniqueness]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeBase (DimDecl VName) ()
-> InternaliseM [TypeBase Shape Uniqueness]
internaliseLoopParamType

-- | As 'internaliseReturnType', but returns components of a top-level
-- tuple type piecemeal.
internaliseEntryReturnType ::
  E.TypeBase (E.DimDecl VName) () ->
  InternaliseM [[I.TypeBase ExtShape Uniqueness]]
internaliseEntryReturnType :: TypeBase (DimDecl VName) ()
-> InternaliseM [[TypeBase ExtShape Uniqueness]]
internaliseEntryReturnType TypeBase (DimDecl VName) ()
et =
  InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
-> InternaliseM [[TypeBase ExtShape Uniqueness]]
forall a. InternaliseTypeM a -> InternaliseM a
runInternaliseTypeM (InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
 -> InternaliseM [[TypeBase ExtShape Uniqueness]])
-> InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
-> InternaliseM [[TypeBase ExtShape Uniqueness]]
forall a b. (a -> b) -> a -> b
$
    (TypeBase (DimDecl VName) ()
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> [TypeBase (DimDecl VName) ()]
-> InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
internaliseTypeM ([TypeBase (DimDecl VName) ()]
 -> InternaliseTypeM [[TypeBase ExtShape Uniqueness]])
-> [TypeBase (DimDecl VName) ()]
-> InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
forall a b. (a -> b) -> a -> b
$
      case TypeBase (DimDecl VName) () -> Maybe [TypeBase (DimDecl VName) ()]
forall dim as. TypeBase dim as -> Maybe [TypeBase dim as]
E.isTupleRecord TypeBase (DimDecl VName) ()
et of
        Just [TypeBase (DimDecl VName) ()]
ets | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [TypeBase (DimDecl VName) ()] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [TypeBase (DimDecl VName) ()]
ets -> [TypeBase (DimDecl VName) ()]
ets
        Maybe [TypeBase (DimDecl VName) ()]
_ -> [TypeBase (DimDecl VName) ()
et]

internaliseType ::
  E.TypeBase (E.DimDecl VName) () ->
  InternaliseM [I.TypeBase I.ExtShape Uniqueness]
internaliseType :: TypeBase (DimDecl VName) ()
-> InternaliseM [TypeBase ExtShape Uniqueness]
internaliseType = InternaliseTypeM [TypeBase ExtShape Uniqueness]
-> InternaliseM [TypeBase ExtShape Uniqueness]
forall a. InternaliseTypeM a -> InternaliseM a
runInternaliseTypeM (InternaliseTypeM [TypeBase ExtShape Uniqueness]
 -> InternaliseM [TypeBase ExtShape Uniqueness])
-> (TypeBase (DimDecl VName) ()
    -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> TypeBase (DimDecl VName) ()
-> InternaliseM [TypeBase ExtShape Uniqueness]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
internaliseTypeM

newId :: InternaliseTypeM Int
newId :: InternaliseTypeM TypeState
newId = do
  TypeState
i <- InternaliseTypeM TypeState
forall s (m :: * -> *). MonadState s m => m s
get
  TypeState -> InternaliseTypeM ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (TypeState -> InternaliseTypeM ())
-> TypeState -> InternaliseTypeM ()
forall a b. (a -> b) -> a -> b
$ TypeState
i TypeState -> TypeState -> TypeState
forall a. Num a => a -> a -> a
+ TypeState
1
  TypeState -> InternaliseTypeM TypeState
forall (m :: * -> *) a. Monad m => a -> m a
return TypeState
i

internaliseDim ::
  E.DimDecl VName ->
  InternaliseTypeM ExtSize
internaliseDim :: DimDecl VName -> InternaliseTypeM ExtSize
internaliseDim DimDecl VName
d =
  case DimDecl VName
d of
    DimDecl VName
E.AnyDim -> TypeState -> ExtSize
forall a. TypeState -> Ext a
Ext (TypeState -> ExtSize)
-> InternaliseTypeM TypeState -> InternaliseTypeM ExtSize
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> InternaliseTypeM TypeState
newId
    E.ConstDim TypeState
n -> ExtSize -> InternaliseTypeM ExtSize
forall (m :: * -> *) a. Monad m => a -> m a
return (ExtSize -> InternaliseTypeM ExtSize)
-> ExtSize -> InternaliseTypeM ExtSize
forall a b. (a -> b) -> a -> b
$ SubExp -> ExtSize
forall a. a -> Ext a
Free (SubExp -> ExtSize) -> SubExp -> ExtSize
forall a b. (a -> b) -> a -> b
$ IntType -> Integer -> SubExp
intConst IntType
I.Int64 (Integer -> SubExp) -> Integer -> SubExp
forall a b. (a -> b) -> a -> b
$ TypeState -> Integer
forall a. Integral a => a -> Integer
toInteger TypeState
n
    E.NamedDim QualName VName
name -> QualName VName -> InternaliseTypeM ExtSize
namedDim QualName VName
name
  where
    namedDim :: QualName VName -> InternaliseTypeM ExtSize
namedDim (E.QualName [VName]
_ VName
name) = do
      Maybe [SubExp]
subst <- InternaliseM (Maybe [SubExp]) -> InternaliseTypeM (Maybe [SubExp])
forall a. InternaliseM a -> InternaliseTypeM a
liftInternaliseM (InternaliseM (Maybe [SubExp])
 -> InternaliseTypeM (Maybe [SubExp]))
-> InternaliseM (Maybe [SubExp])
-> InternaliseTypeM (Maybe [SubExp])
forall a b. (a -> b) -> a -> b
$ VName -> InternaliseM (Maybe [SubExp])
lookupSubst VName
name
      case Maybe [SubExp]
subst of
        Just [SubExp
v] -> ExtSize -> InternaliseTypeM ExtSize
forall (m :: * -> *) a. Monad m => a -> m a
return (ExtSize -> InternaliseTypeM ExtSize)
-> ExtSize -> InternaliseTypeM ExtSize
forall a b. (a -> b) -> a -> b
$ SubExp -> ExtSize
forall a. a -> Ext a
I.Free SubExp
v
        Maybe [SubExp]
_ -> ExtSize -> InternaliseTypeM ExtSize
forall (m :: * -> *) a. Monad m => a -> m a
return (ExtSize -> InternaliseTypeM ExtSize)
-> ExtSize -> InternaliseTypeM ExtSize
forall a b. (a -> b) -> a -> b
$ SubExp -> ExtSize
forall a. a -> Ext a
I.Free (SubExp -> ExtSize) -> SubExp -> ExtSize
forall a b. (a -> b) -> a -> b
$ VName -> SubExp
I.Var VName
name

internaliseTypeM ::
  E.StructType ->
  InternaliseTypeM [I.TypeBase ExtShape Uniqueness]
internaliseTypeM :: TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
internaliseTypeM TypeBase (DimDecl VName) ()
orig_t =
  case TypeBase (DimDecl VName) ()
orig_t of
    E.Array ()
_ Uniqueness
u ScalarTypeBase (DimDecl VName) ()
et ShapeDecl (DimDecl VName)
shape -> do
      [ExtSize]
dims <- ShapeDecl (DimDecl VName) -> InternaliseTypeM [ExtSize]
internaliseShape ShapeDecl (DimDecl VName)
shape
      [TypeBase ExtShape Uniqueness]
ets <- TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
internaliseTypeM (TypeBase (DimDecl VName) ()
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall a b. (a -> b) -> a -> b
$ ScalarTypeBase (DimDecl VName) () -> TypeBase (DimDecl VName) ()
forall dim as. ScalarTypeBase dim as -> TypeBase dim as
E.Scalar ScalarTypeBase (DimDecl VName) ()
et
      [TypeBase ExtShape Uniqueness]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall (m :: * -> *) a. Monad m => a -> m a
return [TypeBase ExtShape Uniqueness
-> ExtShape -> Uniqueness -> TypeBase ExtShape Uniqueness
forall shape u_unused u.
ArrayShape shape =>
TypeBase shape u_unused -> shape -> u -> TypeBase shape u
I.arrayOf TypeBase ExtShape Uniqueness
et' ([ExtSize] -> ExtShape
forall d. [d] -> ShapeBase d
Shape [ExtSize]
dims) (Uniqueness -> TypeBase ExtShape Uniqueness)
-> Uniqueness -> TypeBase ExtShape Uniqueness
forall a b. (a -> b) -> a -> b
$ Uniqueness -> Uniqueness
internaliseUniqueness Uniqueness
u | TypeBase ExtShape Uniqueness
et' <- [TypeBase ExtShape Uniqueness]
ets]
    E.Scalar (E.Prim PrimType
bt) ->
      [TypeBase ExtShape Uniqueness]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall (m :: * -> *) a. Monad m => a -> m a
return [PrimType -> TypeBase ExtShape Uniqueness
forall shape u. PrimType -> TypeBase shape u
I.Prim (PrimType -> TypeBase ExtShape Uniqueness)
-> PrimType -> TypeBase ExtShape Uniqueness
forall a b. (a -> b) -> a -> b
$ PrimType -> PrimType
internalisePrimType PrimType
bt]
    E.Scalar (E.Record Map Name (TypeBase (DimDecl VName) ())
ets)
      -- XXX: we map empty records to bools, because otherwise
      -- arrays of unit will lose their sizes.
      | Map Name (TypeBase (DimDecl VName) ()) -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null Map Name (TypeBase (DimDecl VName) ())
ets -> [TypeBase ExtShape Uniqueness]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall (m :: * -> *) a. Monad m => a -> m a
return [PrimType -> TypeBase ExtShape Uniqueness
forall shape u. PrimType -> TypeBase shape u
I.Prim PrimType
I.Bool]
      | Bool
otherwise ->
        [[TypeBase ExtShape Uniqueness]] -> [TypeBase ExtShape Uniqueness]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[TypeBase ExtShape Uniqueness]]
 -> [TypeBase ExtShape Uniqueness])
-> InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, TypeBase (DimDecl VName) ())
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> [(Name, TypeBase (DimDecl VName) ())]
-> InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
internaliseTypeM (TypeBase (DimDecl VName) ()
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> ((Name, TypeBase (DimDecl VName) ())
    -> TypeBase (DimDecl VName) ())
-> (Name, TypeBase (DimDecl VName) ())
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name, TypeBase (DimDecl VName) ()) -> TypeBase (DimDecl VName) ()
forall a b. (a, b) -> b
snd) (Map Name (TypeBase (DimDecl VName) ())
-> [(Name, TypeBase (DimDecl VName) ())]
forall a. Map Name a -> [(Name, a)]
E.sortFields Map Name (TypeBase (DimDecl VName) ())
ets)
    E.Scalar E.TypeVar {} ->
      [Char] -> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall a. HasCallStack => [Char] -> a
error [Char]
"internaliseTypeM: cannot handle type variable."
    E.Scalar E.Arrow {} ->
      [Char] -> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall a. HasCallStack => [Char] -> a
error ([Char] -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> [Char] -> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall a b. (a -> b) -> a -> b
$ [Char]
"internaliseTypeM: cannot handle function type: " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ TypeBase (DimDecl VName) () -> [Char]
forall a. Pretty a => a -> [Char]
pretty TypeBase (DimDecl VName) ()
orig_t
    E.Scalar (E.Sum Map Name [TypeBase (DimDecl VName) ()]
cs) -> do
      ([TypeBase ExtShape Uniqueness]
ts, Map Name (TypeState, [TypeState])
_) <-
        Map Name [TypeBase ExtShape Uniqueness]
-> ([TypeBase ExtShape Uniqueness],
    Map Name (TypeState, [TypeState]))
internaliseConstructors
          (Map Name [TypeBase ExtShape Uniqueness]
 -> ([TypeBase ExtShape Uniqueness],
     Map Name (TypeState, [TypeState])))
-> InternaliseTypeM (Map Name [TypeBase ExtShape Uniqueness])
-> InternaliseTypeM
     ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ([TypeBase (DimDecl VName) ()]
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> Map Name [TypeBase (DimDecl VName) ()]
-> InternaliseTypeM (Map Name [TypeBase ExtShape Uniqueness])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (([[TypeBase ExtShape Uniqueness]]
 -> [TypeBase ExtShape Uniqueness])
-> InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [[TypeBase ExtShape Uniqueness]] -> [TypeBase ExtShape Uniqueness]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> ([TypeBase (DimDecl VName) ()]
    -> InternaliseTypeM [[TypeBase ExtShape Uniqueness]])
-> [TypeBase (DimDecl VName) ()]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeBase (DimDecl VName) ()
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> [TypeBase (DimDecl VName) ()]
-> InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
internaliseTypeM) Map Name [TypeBase (DimDecl VName) ()]
cs
      [TypeBase ExtShape Uniqueness]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall (m :: * -> *) a. Monad m => a -> m a
return ([TypeBase ExtShape Uniqueness]
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> [TypeBase ExtShape Uniqueness]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall a b. (a -> b) -> a -> b
$ PrimType -> TypeBase ExtShape Uniqueness
forall shape u. PrimType -> TypeBase shape u
I.Prim (IntType -> PrimType
I.IntType IntType
I.Int8) TypeBase ExtShape Uniqueness
-> [TypeBase ExtShape Uniqueness] -> [TypeBase ExtShape Uniqueness]
forall a. a -> [a] -> [a]
: [TypeBase ExtShape Uniqueness]
ts
  where
    internaliseShape :: ShapeDecl (DimDecl VName) -> InternaliseTypeM [ExtSize]
internaliseShape = (DimDecl VName -> InternaliseTypeM ExtSize)
-> [DimDecl VName] -> InternaliseTypeM [ExtSize]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM DimDecl VName -> InternaliseTypeM ExtSize
internaliseDim ([DimDecl VName] -> InternaliseTypeM [ExtSize])
-> (ShapeDecl (DimDecl VName) -> [DimDecl VName])
-> ShapeDecl (DimDecl VName)
-> InternaliseTypeM [ExtSize]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShapeDecl (DimDecl VName) -> [DimDecl VName]
forall dim. ShapeDecl dim -> [dim]
E.shapeDims

internaliseConstructors ::
  M.Map Name [I.TypeBase ExtShape Uniqueness] ->
  ( [I.TypeBase ExtShape Uniqueness],
    M.Map Name (Int, [Int])
  )
internaliseConstructors :: Map Name [TypeBase ExtShape Uniqueness]
-> ([TypeBase ExtShape Uniqueness],
    Map Name (TypeState, [TypeState]))
internaliseConstructors Map Name [TypeBase ExtShape Uniqueness]
cs =
  (([TypeBase ExtShape Uniqueness],
  Map Name (TypeState, [TypeState]))
 -> ((Name, [TypeBase ExtShape Uniqueness]), TypeState)
 -> ([TypeBase ExtShape Uniqueness],
     Map Name (TypeState, [TypeState])))
-> ([TypeBase ExtShape Uniqueness],
    Map Name (TypeState, [TypeState]))
-> [((Name, [TypeBase ExtShape Uniqueness]), TypeState)]
-> ([TypeBase ExtShape Uniqueness],
    Map Name (TypeState, [TypeState]))
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
-> ((Name, [TypeBase ExtShape Uniqueness]), TypeState)
-> ([TypeBase ExtShape Uniqueness],
    Map Name (TypeState, [TypeState]))
forall k (t :: * -> *) shape a.
(Ord k, Foldable t, Eq shape) =>
([TypeBase shape Uniqueness], Map k (a, [TypeState]))
-> ((k, t (TypeBase shape Uniqueness)), a)
-> ([TypeBase shape Uniqueness], Map k (a, [TypeState]))
onConstructor ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
forall a. Monoid a => a
mempty ([((Name, [TypeBase ExtShape Uniqueness]), TypeState)]
 -> ([TypeBase ExtShape Uniqueness],
     Map Name (TypeState, [TypeState])))
-> [((Name, [TypeBase ExtShape Uniqueness]), TypeState)]
-> ([TypeBase ExtShape Uniqueness],
    Map Name (TypeState, [TypeState]))
forall a b. (a -> b) -> a -> b
$ [(Name, [TypeBase ExtShape Uniqueness])]
-> [TypeState]
-> [((Name, [TypeBase ExtShape Uniqueness]), TypeState)]
forall a b. [a] -> [b] -> [(a, b)]
zip (Map Name [TypeBase ExtShape Uniqueness]
-> [(Name, [TypeBase ExtShape Uniqueness])]
forall a. Map Name a -> [(Name, a)]
E.sortConstrs Map Name [TypeBase ExtShape Uniqueness]
cs) [TypeState
0 ..]
  where
    onConstructor :: ([TypeBase shape Uniqueness], Map k (a, [TypeState]))
-> ((k, t (TypeBase shape Uniqueness)), a)
-> ([TypeBase shape Uniqueness], Map k (a, [TypeState]))
onConstructor ([TypeBase shape Uniqueness]
ts, Map k (a, [TypeState])
mapping) ((k
c, t (TypeBase shape Uniqueness)
c_ts), a
i) =
      let ([(TypeBase shape NoUniqueness, TypeState)]
_, [TypeState]
js, [TypeBase shape Uniqueness]
new_ts) =
            (([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
  [TypeBase shape Uniqueness])
 -> TypeBase shape Uniqueness
 -> ([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
     [TypeBase shape Uniqueness]))
-> ([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
    [TypeBase shape Uniqueness])
-> t (TypeBase shape Uniqueness)
-> ([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
    [TypeBase shape Uniqueness])
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' ([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
 [TypeBase shape Uniqueness])
-> TypeBase shape Uniqueness
-> ([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
    [TypeBase shape Uniqueness])
forall shape.
Eq shape =>
([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
 [TypeBase shape Uniqueness])
-> TypeBase shape Uniqueness
-> ([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
    [TypeBase shape Uniqueness])
f ([TypeBase shape NoUniqueness]
-> [TypeState] -> [(TypeBase shape NoUniqueness, TypeState)]
forall a b. [a] -> [b] -> [(a, b)]
zip ((TypeBase shape Uniqueness -> TypeBase shape NoUniqueness)
-> [TypeBase shape Uniqueness] -> [TypeBase shape NoUniqueness]
forall a b. (a -> b) -> [a] -> [b]
map TypeBase shape Uniqueness -> TypeBase shape NoUniqueness
forall shape.
TypeBase shape Uniqueness -> TypeBase shape NoUniqueness
fromDecl [TypeBase shape Uniqueness]
ts) [TypeState
0 ..], [TypeState]
forall a. Monoid a => a
mempty, [TypeBase shape Uniqueness]
forall a. Monoid a => a
mempty) t (TypeBase shape Uniqueness)
c_ts
       in ([TypeBase shape Uniqueness]
ts [TypeBase shape Uniqueness]
-> [TypeBase shape Uniqueness] -> [TypeBase shape Uniqueness]
forall a. [a] -> [a] -> [a]
++ [TypeBase shape Uniqueness]
new_ts, k
-> (a, [TypeState])
-> Map k (a, [TypeState])
-> Map k (a, [TypeState])
forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert k
c (a
i, [TypeState]
js) Map k (a, [TypeState])
mapping)
      where
        f :: ([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
 [TypeBase shape Uniqueness])
-> TypeBase shape Uniqueness
-> ([(TypeBase shape NoUniqueness, TypeState)], [TypeState],
    [TypeBase shape Uniqueness])
f ([(TypeBase shape NoUniqueness, TypeState)]
ts', [TypeState]
js, [TypeBase shape Uniqueness]
new_ts) TypeBase shape Uniqueness
t
          | Just (TypeBase shape NoUniqueness
_, TypeState
j) <- ((TypeBase shape NoUniqueness, TypeState) -> Bool)
-> [(TypeBase shape NoUniqueness, TypeState)]
-> Maybe (TypeBase shape NoUniqueness, TypeState)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find ((TypeBase shape NoUniqueness -> TypeBase shape NoUniqueness -> Bool
forall a. Eq a => a -> a -> Bool
== TypeBase shape Uniqueness -> TypeBase shape NoUniqueness
forall shape.
TypeBase shape Uniqueness -> TypeBase shape NoUniqueness
fromDecl TypeBase shape Uniqueness
t) (TypeBase shape NoUniqueness -> Bool)
-> ((TypeBase shape NoUniqueness, TypeState)
    -> TypeBase shape NoUniqueness)
-> (TypeBase shape NoUniqueness, TypeState)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeBase shape NoUniqueness, TypeState)
-> TypeBase shape NoUniqueness
forall a b. (a, b) -> a
fst) [(TypeBase shape NoUniqueness, TypeState)]
ts' =
            ( (TypeBase shape NoUniqueness, TypeState)
-> [(TypeBase shape NoUniqueness, TypeState)]
-> [(TypeBase shape NoUniqueness, TypeState)]
forall a. Eq a => a -> [a] -> [a]
delete (TypeBase shape Uniqueness -> TypeBase shape NoUniqueness
forall shape.
TypeBase shape Uniqueness -> TypeBase shape NoUniqueness
fromDecl TypeBase shape Uniqueness
t, TypeState
j) [(TypeBase shape NoUniqueness, TypeState)]
ts',
              [TypeState]
js [TypeState] -> [TypeState] -> [TypeState]
forall a. [a] -> [a] -> [a]
++ [TypeState
j],
              [TypeBase shape Uniqueness]
new_ts
            )
          | Bool
otherwise =
            ( [(TypeBase shape NoUniqueness, TypeState)]
ts',
              [TypeState]
js [TypeState] -> [TypeState] -> [TypeState]
forall a. [a] -> [a] -> [a]
++ [[TypeBase shape Uniqueness] -> TypeState
forall (t :: * -> *) a. Foldable t => t a -> TypeState
length [TypeBase shape Uniqueness]
ts TypeState -> TypeState -> TypeState
forall a. Num a => a -> a -> a
+ [TypeBase shape Uniqueness] -> TypeState
forall (t :: * -> *) a. Foldable t => t a -> TypeState
length [TypeBase shape Uniqueness]
new_ts],
              [TypeBase shape Uniqueness]
new_ts [TypeBase shape Uniqueness]
-> [TypeBase shape Uniqueness] -> [TypeBase shape Uniqueness]
forall a. [a] -> [a] -> [a]
++ [TypeBase shape Uniqueness
t]
            )

internaliseSumType ::
  M.Map Name [E.StructType] ->
  InternaliseM
    ( [I.TypeBase ExtShape Uniqueness],
      M.Map Name (Int, [Int])
    )
internaliseSumType :: Map Name [TypeBase (DimDecl VName) ()]
-> InternaliseM
     ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
internaliseSumType Map Name [TypeBase (DimDecl VName) ()]
cs =
  InternaliseTypeM
  ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
-> InternaliseM
     ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
forall a. InternaliseTypeM a -> InternaliseM a
runInternaliseTypeM (InternaliseTypeM
   ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
 -> InternaliseM
      ([TypeBase ExtShape Uniqueness],
       Map Name (TypeState, [TypeState])))
-> InternaliseTypeM
     ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
-> InternaliseM
     ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
forall a b. (a -> b) -> a -> b
$
    Map Name [TypeBase ExtShape Uniqueness]
-> ([TypeBase ExtShape Uniqueness],
    Map Name (TypeState, [TypeState]))
internaliseConstructors
      (Map Name [TypeBase ExtShape Uniqueness]
 -> ([TypeBase ExtShape Uniqueness],
     Map Name (TypeState, [TypeState])))
-> InternaliseTypeM (Map Name [TypeBase ExtShape Uniqueness])
-> InternaliseTypeM
     ([TypeBase ExtShape Uniqueness], Map Name (TypeState, [TypeState]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ([TypeBase (DimDecl VName) ()]
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> Map Name [TypeBase (DimDecl VName) ()]
-> InternaliseTypeM (Map Name [TypeBase ExtShape Uniqueness])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (([[TypeBase ExtShape Uniqueness]]
 -> [TypeBase ExtShape Uniqueness])
-> InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [[TypeBase ExtShape Uniqueness]] -> [TypeBase ExtShape Uniqueness]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> ([TypeBase (DimDecl VName) ()]
    -> InternaliseTypeM [[TypeBase ExtShape Uniqueness]])
-> [TypeBase (DimDecl VName) ()]
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeBase (DimDecl VName) ()
 -> InternaliseTypeM [TypeBase ExtShape Uniqueness])
-> [TypeBase (DimDecl VName) ()]
-> InternaliseTypeM [[TypeBase ExtShape Uniqueness]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeBase (DimDecl VName) ()
-> InternaliseTypeM [TypeBase ExtShape Uniqueness]
internaliseTypeM) Map Name [TypeBase (DimDecl VName) ()]
cs

-- | How many core language values are needed to represent one source
-- language value of the given type?
internalisedTypeSize :: E.TypeBase (E.DimDecl VName) () -> InternaliseM Int
internalisedTypeSize :: TypeBase (DimDecl VName) () -> InternaliseM TypeState
internalisedTypeSize = ([TypeBase ExtShape Uniqueness] -> TypeState)
-> InternaliseM [TypeBase ExtShape Uniqueness]
-> InternaliseM TypeState
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [TypeBase ExtShape Uniqueness] -> TypeState
forall (t :: * -> *) a. Foldable t => t a -> TypeState
length (InternaliseM [TypeBase ExtShape Uniqueness]
 -> InternaliseM TypeState)
-> (TypeBase (DimDecl VName) ()
    -> InternaliseM [TypeBase ExtShape Uniqueness])
-> TypeBase (DimDecl VName) ()
-> InternaliseM TypeState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeBase (DimDecl VName) ()
-> InternaliseM [TypeBase ExtShape Uniqueness]
internaliseType

-- | Convert an external primitive to an internal primitive.
internalisePrimType :: E.PrimType -> I.PrimType
internalisePrimType :: PrimType -> PrimType
internalisePrimType (E.Signed IntType
t) = IntType -> PrimType
I.IntType IntType
t
internalisePrimType (E.Unsigned IntType
t) = IntType -> PrimType
I.IntType IntType
t
internalisePrimType (E.FloatType FloatType
t) = FloatType -> PrimType
I.FloatType FloatType
t
internalisePrimType PrimType
E.Bool = PrimType
I.Bool

-- | Convert an external primitive value to an internal primitive value.
internalisePrimValue :: E.PrimValue -> I.PrimValue
internalisePrimValue :: PrimValue -> PrimValue
internalisePrimValue (E.SignedValue IntValue
v) = IntValue -> PrimValue
I.IntValue IntValue
v
internalisePrimValue (E.UnsignedValue IntValue
v) = IntValue -> PrimValue
I.IntValue IntValue
v
internalisePrimValue (E.FloatValue FloatValue
v) = FloatValue -> PrimValue
I.FloatValue FloatValue
v
internalisePrimValue (E.BoolValue Bool
b) = Bool -> PrimValue
I.BoolValue Bool
b