type-families Questions

1

I have a multi-parameter typeclass with a functional dependency: class Multi a b | a -> b I also have a simple, non-injective type synonym family: type family Fam a I want to write an inst...
Judson asked 27/7, 2017 at 21:2

1

Messing around with GHC's DataKinds, I tried implementing type-level binary nats. They're simple enough to implement, but if I want them to be useful in common cases, then GHC needs to believe that...
Handler asked 14/1, 2018 at 15:21

2

I have a typeclass A with a non injective associated type Context class A a where type Context a so many instances of A can have the same Context. Some instances of A are also instances of the cl...
Intoxicated asked 20/12, 2023 at 12:19

1

Solved

Is there any way to write a type family that sometimes evaluates to a constrained type such as C a => T? This question arose when I was writing the following type family: type family Function (c...
Solifluction asked 19/8, 2023 at 6:6

3

Solved

Take this code snippet (I changed the type family to a closed one after the various comments and answers mentioned it): -- a closed type family for which I won't define any instances type family Em...
Alleyway asked 26/1, 2023 at 6:0

0

I am quite new to type level programming in haskell and I'm stuck with the following example. It is a fragment of a type level type checker for a small dsl. I want the Find type family to return a ...
Raeraeann asked 12/4, 2022 at 16:17

1

Solved

This recursive definition of T fails to type-check. class C a where type T a :: Type newtype Compose (f :: Type -> Type) (g :: Type -> Type) (a :: Type) = Compose {getCompose :: f (g a)} i...
Cylindroid asked 9/2, 2022 at 20:32

1

Solved

I understand how to define both homogeneous and heterogeneous streams in Haskell. -- Type-invariant streams. data InvStream a where (:::) :: a -> InvStream a -> InvStream a -- Heterogeneous...
Suksukarno asked 23/11, 2021 at 14:45

1

Solved

While I was going through the haskell-excercises questions. I saw the following code which creates an aggregate Constraint by applying each type to a Constraint constructor. In GHC it seems deeply ...
Outwardbound asked 10/8, 2021 at 16:17

0

Oftentimes, whenever working with monoidal operators in Haskell (or in any other languages for that matter), I find myself asking "Wouldn't it be convenient if the language itself had support ...
Hester asked 15/5, 2021 at 17:33

1

Solved

Why is GHC inferring unification from coercibility of associated data, and why is it contradicting its own checked type signature to do so? The problem {-# LANGUAGE ExplicitForAll #-} {-# LANGUAGE ...
Pipsissewa asked 24/12, 2020 at 12:39

1

Solved

Summary I have a typeclass for which I want to write some 'generic terms'. I have two questions: Using :t to ask GHCi for the type of a generic term works, but using that inferred type fails- why?...
Lycurgus asked 19/12, 2020 at 11:34

2

Solved

For example, if I have these weird types: {-# LANGUAGE TypeFamilies #-} type family WeirdFamily a type instance WeirdFamily () = Int type instance WeirdFamily (a, b) = (a, WeirdFamily b) Can I dis...
Pence asked 19/7, 2020 at 10:58

0

In the following example: {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilyDependencies #-} {-# LANGUAGE PolyKinds #-} newtype A a b = A (a, b) type family F (x :: k) = (r :: k) | r -> x typ...
Reinert asked 3/7, 2020 at 9:0

2

I am trying to use this blogpost's approach to higher-kinded data without dangling Identity functors for the trival case together with quantified-constraint deriving: {-# LANGUAGE TypeFamilies #-}...

1

My issue I have the following type family that splits arguments off of a function: type family SeparateArgs ( a :: Type ) :: ( Type, [Type] ) where SeparateArgs (a -> b) = SndCons2 a (Se...

1

Solved

I have wrapped up whole data family in a single existential: data Type = Numeric | Boolean data family Operator (t :: Type) data instance Operator 'Numeric = Add | Sub data instance Operator 'Bo...
Reitman asked 28/10, 2019 at 11:32

1

Solved

GHC.TypeNats exports type family of the following signature: type family (m :: Nat) + (n :: Nat) :: Nat How can I import it explicitly? import GHC.TypeNats((+)) does not work, because it says t...
Phlegm asked 25/10, 2019 at 20:44

3

Consider following definition of a HList: infixr 5 :> data HList (types :: [*]) where HNil :: HList '[] (:>) :: a -> HList l -> HList (a:l) And a type family Map to map over typele...

1

Solved

I have the following code: {-# LANGUAGE TypeFamilies #-} type family Times (a :: Nat) (b :: Nat) :: Nat where Times Z n = Z Times (S m) n = Plus n (Times m n) I know that type families allow ...
Longboat asked 2/8, 2019 at 1:57

2

Solved

To motivate this question, let's first recall a bog-standard Hoare-Dijkstra-style indexed monad, and the example instance of an indexed writer monad. For an indexed monad, we just require type ali...
Debi asked 15/7, 2019 at 13:1

2

Solved

I've got a type family defined as follows: type family Vec a (n :: Nat) where Vec a Z = a Vec a (S n) = (a, Vec a n) I'd like to assert that the result of applying this type family always fulf...
Appendicle asked 4/7, 2019 at 0:31

1

Solved

I'm looking at the references at the backpack wiki trying to understand in which cases the use of backpack would be considered appropriate over other Haskell features like type-classes and type-fam...
Decolonize asked 27/9, 2018 at 13:29

1

Solved

I tried this: {-# LANGUAGE TypeFamilyDependencies #-} module Injective where type family F (a :: *) = (fa :: *) | fa -> a convert :: F a ~ F b => a -> b convert x = x GHC 8.6.4 gave m...
Arkwright asked 5/4, 2019 at 21:28

1

Solved

In the routing section, the article says: We can see that the RenderRoute class defines an associated data type providing the routes for our application. What does associated data type mean?...
Lentigo asked 27/2, 2019 at 11:21

© 2022 - 2024 — McMap. All rights reserved.