Skip to content

Instantly share code, notes, and snippets.

@Shimuuar
Created August 17, 2014 21:25
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 Shimuuar/db3dbe64a07466e26f83 to your computer and use it in GitHub Desktop.
Save Shimuuar/db3dbe64a07466e26f83 to your computer and use it in GitHub Desktop.
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
module TySet where
import Data.Typeable
import GHC.TypeLits
class UpdateCompose (k :: Nat) (v :: Nat) where
update :: Proxy k -> Proxy v -> [Double] -> [Double]
instance UpdateComposeCase (k <=? v) k v => UpdateCompose k v where
update = updateCase (Proxy :: Proxy (k <=? v))
class UpdateComposeCase (leq :: Bool) (k :: Nat) (v::Nat) where
updateCase :: Proxy leq -> Proxy k -> Proxy v -> [Double] -> [Double]
instance UpdateComposeCase True k v where
updateCase _ _ _ = id
instance UpdateComposeCase False k v where
updateCase _ _ _ = error "Something meaningful"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment