Skip to content

Instantly share code, notes, and snippets.

@kozross
Created October 27, 2018 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kozross/9bc9cfd7d90e3d8c09ebecdfd18c40dc to your computer and use it in GitHub Desktop.
Save kozross/9bc9cfd7d90e3d8c09ebecdfd18c40dc to your computer and use it in GitHub Desktop.
{-# 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