summaryrefslogtreecommitdiff
path: root/compiler/vectorise/Vectorise/Utils.hs
diff options
context:
space:
mode:
authorRichard Eisenberg <eir@cis.upenn.edu>2015-12-11 18:19:53 -0500
committerRichard Eisenberg <eir@cis.upenn.edu>2015-12-11 18:23:12 -0500
commit6746549772c5cc0ac66c0fce562f297f4d4b80a2 (patch)
tree96869fcfb5757651462511d64d99a3712f09e7fb /compiler/vectorise/Vectorise/Utils.hs
parent6e56ac58a6905197412d58e32792a04a63b94d7e (diff)
downloadhaskell-6746549772c5cc0ac66c0fce562f297f4d4b80a2.tar.gz
Add kind equalities to GHC.
This implements the ideas originally put forward in "System FC with Explicit Kind Equality" (ICFP'13). There are several noteworthy changes with this patch: * We now have casts in types. These change the kind of a type. See new constructor `CastTy`. * All types and all constructors can be promoted. This includes GADT constructors. GADT pattern matches take place in type family equations. In Core, types can now be applied to coercions via the `CoercionTy` constructor. * Coercions can now be heterogeneous, relating types of different kinds. A coercion proving `t1 :: k1 ~ t2 :: k2` proves both that `t1` and `t2` are the same and also that `k1` and `k2` are the same. * The `Coercion` type has been significantly enhanced. The documentation in `docs/core-spec/core-spec.pdf` reflects the new reality. * The type of `*` is now `*`. No more `BOX`. * Users can write explicit kind variables in their code, anywhere they can write type variables. For backward compatibility, automatic inference of kind-variable binding is still permitted. * The new extension `TypeInType` turns on the new user-facing features. * Type families and synonyms are now promoted to kinds. This causes trouble with parsing `*`, leading to the somewhat awkward new `HsAppsTy` constructor for `HsType`. This is dispatched with in the renamer, where the kind `*` can be told apart from a type-level multiplication operator. Without `-XTypeInType` the old behavior persists. With `-XTypeInType`, you need to import `Data.Kind` to get `*`, also known as `Type`. * The kind-checking algorithms in TcHsType have been significantly rewritten to allow for enhanced kinds. * The new features are still quite experimental and may be in flux. * TODO: Several open tickets: #11195, #11196, #11197, #11198, #11203. * TODO: Update user manual. Tickets addressed: #9017, #9173, #7961, #10524, #8566, #11142. Updates Haddock submodule.
Diffstat (limited to 'compiler/vectorise/Vectorise/Utils.hs')
-rw-r--r--compiler/vectorise/Vectorise/Utils.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/vectorise/Vectorise/Utils.hs b/compiler/vectorise/Vectorise/Utils.hs
index fafce7a67d..733eeb9cfd 100644
--- a/compiler/vectorise/Vectorise/Utils.hs
+++ b/compiler/vectorise/Vectorise/Utils.hs
@@ -48,7 +48,7 @@ collectAnnTypeArgs expr = go expr []
collectAnnDictArgs :: AnnExpr Var ann -> (AnnExpr Var ann, [AnnExpr Var ann])
collectAnnDictArgs expr = go expr []
where
- go e@(_, AnnApp f arg) dicts
+ go e@(_, AnnApp f arg) dicts
| isPredTy . exprType . deAnnotate $ arg = go f (arg : dicts)
| otherwise = (e, dicts)
go e dicts = (e, dicts)
@@ -64,7 +64,7 @@ collectAnnTypeBinders expr = go [] expr
collectAnnValBinders :: AnnExpr Var ann -> ([Var], AnnExpr Var ann)
collectAnnValBinders expr = go [] expr
where
- go bs (_, AnnLam b e) | isId b
+ go bs (_, AnnLam b e) | isId b
&& (not . isPredTy . idType $ b) = go (b : bs) e
go bs e = (reverse bs, e)
@@ -75,7 +75,7 @@ isAnnTypeArg _ = False
-- PD "Parallel Data" Functions -----------------------------------------------
--
--- Given some data that has a PA dictionary, we can convert it to its
+-- Given some data that has a PA dictionary, we can convert it to its
-- representation type, perform some operation on the data, then convert it back.
--
-- In the DPH backend, the types of these functions are defined
@@ -92,14 +92,14 @@ emptyPD = paMethod emptyPDVar emptyPD_PrimVar
replicatePD :: CoreExpr -- ^ Number of copies in the resulting array.
-> CoreExpr -- ^ Value to replicate.
-> VM CoreExpr
-replicatePD len x
+replicatePD len x
= liftM (`mkApps` [len,x])
$ paMethod replicatePDVar replicatePD_PrimVar (exprType x)
-- |Select some elements from an array that correspond to a particular tag value and pack them into a new
-- array.
--
--- > packByTagPD Int# [:23, 42, 95, 50, 27, 49:] 3 [:1, 2, 1, 2, 3, 2:] 2
+-- > packByTagPD Int# [:23, 42, 95, 50, 27, 49:] 3 [:1, 2, 1, 2, 3, 2:] 2
-- > ==> [:42, 50, 49:]
--
packByTagPD :: Type -- ^ Element type.
@@ -146,7 +146,7 @@ isScalar ty
zipScalars :: [Type] -> Type -> VM CoreExpr
zipScalars arg_tys res_ty
- = do
+ = do
{ scalar <- builtin scalarClass
; (dfuns, _) <- mapAndUnzipM (\ty -> lookupInst scalar [ty]) ty_args
; zipf <- builtin (scalarZip $ length arg_tys)