正规365体育投注

Dark mode beta

You’ve been asking for dark mode for years.
The is finally here.

Change your preferences any time.

Questions tagged [typeclass]

Type classes in Haskell are a language mechanism to support ad hoc polymorphism. They also exist in Scala, Coq, and Isabelle.

Filter by
Sorted by
Tagged with
0
votes
1answer
15 views

Getting type class instance through a parent type

I need to provide type class instances for a bunch of case classes all derived from a single trait, but as far as I understand Scala compiler expects an instance for a specific class and doesn't go up ...
5
votes
1answer
56 views

Why can a parameter accept any construction of a typeclass but its value can't be constructed conditionally?

I'm fairly new to Haskell, though not to programming, and I've been using the req library to perform HTTPS requests. In order to retain some generality, there will be two types of request - one to ...
0
votes
1answer
33 views

How to specify a typeclass for data classes in Kotlin

In scala the parent class backing the case class is product : so we can use that for polymorphism across case classees. How can a similar goal be achieved for data classes in kotlin? For the yaml ...
9
votes
1answer
120 views

Why isn't the “constraint trick” working in this manually defined HasField instance?

I have this (admittedly weird) code which uses lens and GHC.Records: {-# LANGUAGE DataKinds, PolyKinds, FlexibleInstances, UndecidableInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ...
1
vote
1answer
60 views

Mutually recursively defined typeclass methods with defaults

I would like to define a typeclass that has two methods, where implementing any one is enough (but you can implement both independently if needed). This situation is the same as in Eq, where x == y = ...
0
votes
2answers
69 views

How to extract types from a tuple that implements a typeclass

Function a can receive single argument or a tuple, these arguments need to be members of typeclass StringIdentifiable How to extract and decompose tuple type into types that also have instances of ...
2
votes
2answers
33 views

Can I change the notation in a built-in Isabelle type-class

I have made a type of mine an instance of monoid_add: instantiation "marking_ext" :: (monoid_add) monoid_add begin definition marking_add_def: "M + N = ... end I can now use the ...
5
votes
0answers
64 views

Making a commutative class?

I have a couple of classes of the form class R a b For the purposes of examples we will use the following simplified class: class R1 a b where q :: a -> b -> Bool Which express some ...
1
vote
1answer
76 views

How can I let Haskell know I don't care what a generic's type is?

I'm working on some code deep in the bowels of an application and would like to make it generic w.r.t. some of the types it's using so I can mock the types for unit tests. I'm trying to setup a type-...
0
votes
1answer
46 views

Interpreters for two polymorphic classes in one function

I have this polymorphic code (see this question) with generic monads for model and client: import Control.Monad.Writer class Monad m => Model m where act :: Client c => String -> c a ->...
3
votes
1answer
55 views

Two polymorphic classes in one function

I have this code with State monads: import Control.Monad.State data ModelData = ModelData String data ClientData = ClientData String act :: String -> State ClientData a -> State ModelData a ...
4
votes
0answers
69 views

Inductive lifting

I would like to combine the various lifts into a single class class Lift a b where lift :: a -> b So that lift can be used in place of fmap, liftA2, liftA3, etc. Now it is easy enough to write ...
4
votes
1answer
67 views

GHC infers my ambiguous type to make constraint succeed

At my very early stages of implementing a type-level encoded tree, I came across GHC's peculiar behavior in its type inference when faced with ambiguous types when it involves type constraints. I ...
9
votes
1answer
86 views

Implicit, static type cast (coercion) in Haskell

Problem Consider the following design problem in Haskell. I have a simple, symbolic EDSL in which I want to express variables and general expressions (multivariate polynomials) such as x^2 * y + 2*z +...
0
votes
1answer
25 views

Do many classes slow down my Angular application

In my angular 7 application I created 200 to 300 of classes for model types ex: component.model.ts (only type checking purpose). I am not creating any objects for those classes. When I was ...

15 30 50 per page
1
2 3 4 5
109