phantom-types Questions
3
Solved
I understand that many of the names in Haskell are inspired by category theory terminology, and I'm trying to understand exactly where the analogy begins and ends.
The Category Hask
I already know ...
Airdrie asked 21/4, 2021 at 5:43
1
Solved
I find the concept of PhantomData in Rust quite confusing. I use it extensively to constrain object lifetimes in my FFI-based code, and I am still not sure whether I do it correctly or not.
Here's...
Skeens asked 19/4, 2020 at 17:16
2
Suppose I have a parameter that exists only for the benefit of the type system, for example as in this small program:
{-# LANGUAGE GADTs #-}
module Main where
import Data.Proxy
import Data.List
d...
Pamela asked 22/3, 2020 at 21:5
2
Solved
I was going through some rust source code and I found a data type called PhantomData. I was going through the rust documentation and searched through the internet a lot. However, I couldn't underst...
Lalise asked 8/9, 2019 at 19:6
1
Solved
I'm trying to implement a CurrencyQty type that acts like a number tagged at compile time:
data Currency = Usd | Eur | Gbp
data CurrencyQty (a :: Currency) = CurrencyQty Double deriving (Num)
A...
Madelinemadella asked 12/9, 2018 at 16:11
2
Solved
I have a structure that needs to be generic over a type, yet the type is not actually contained in the structure: it's used in methods of this structure, not in the structure itself. And so, the st...
Abstention asked 6/5, 2018 at 13:24
1
Solved
I'm currently going through the Type-Driven Development with Idris book.
I have two questions relating to the design of the example data store in Chapter 6. The data store is a command line applic...
Kanzu asked 4/8, 2017 at 10:5
2
Solved
I'm trying to learn more about Phantom Types. I'm trying to read through Fun with Phantom Types by Ralf Hinze. He's using a keyword with I haven't seen before and that I can't get to compile. I get...
Pavla asked 30/9, 2015 at 16:20
4
Solved
I'm learning about existential quantification, phantom types, and GADTs at the moment. How do I go about creating a heterogeneous list of a data type with a phantom variable? For example:
{-# LANG...
Souffle asked 10/2, 2015 at 17:30
3
Solved
Don Stewart's Haskell in the Large's presentation mentioned Phantom Types:
data Ratio n = Ratio Double
1.234 :: Ratio D3
data Ask ccy = Ask Double
Ask 1.5123 :: Ask GBP
I read over his bullet p...
Beneficent asked 31/1, 2015 at 2:30
2
Solved
Is it possible to write something like an identity function with phantom types, with the purpose of converting the type?
For example, given the following type definitions
data Nucleotide a = A |...
Swanhildas asked 2/11, 2014 at 4:34
1
Solved
Suppose I have:
class Bounded[A] {
type apply[C <: A] = C
}
This compiles:
implicitly[Bounded[Any]#apply[String] =:= String]
This fails:
type Str = Bounded[Any]#apply[String]
...with:
...
Southerly asked 6/10, 2014 at 19:15
2
So I'm trying to make a type for variable-length tuples, basically as a prettier version of Either a (Either (a,b) (Either (a,b,c) ...)) and Either (Either (Either ... (x,y,z)) (y,z)) z.
{-# LANGU...
Goldenrod asked 16/1, 2012 at 22:6
1
© 2022 - 2025 — McMap. All rights reserved.