Created
October 27, 2018 06:40
-
-
Save kozross/9bc9cfd7d90e3d8c09ebecdfd18c40dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds, DeriveFunctor, GADTs, KindSignatures, | |
ScopedTypeVariables, TemplateHaskell, TypeFamilies, | |
TypeApplications #-} | |
module Data.Massiv.Array.Sized.One where | |
import CoercibleUtils | |
import Data.Coerce | |
import Data.Finite | |
import Data.Foldable | |
import Data.Kind | |
import Data.Proxy | |
import Data.Singletons | |
import Data.Singletons.TH | |
import Data.Singletons.TypeLits | |
import Numeric | |
import qualified Data.Massiv.Array as MA | |
data Strategy | |
= Seq | |
| Par | |
genSingletons [''Strategy] | |
newtype DelayArray (s :: Strategy) (n :: Nat) (a :: Type) = | |
DelayArray (MA.Array MA.D MA.Ix1 a) | |
deriving (Eq, Ord, Show, Functor) | |
-- Given that 's' can _only_ be of kind Strategy, why do I need the SingI s constraint here? | |
-- Shouldn't it know that it must have a SingI, or am I missing something? | |
instance (SingI s, KnownNat n) => Applicative (DelayArray s n) where | |
pure = make . const | |
(<*>) = coerce (MA.zipWith ($)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment