ghc-generics Questions
2
Solved
How would I go about deriving the function
getField :: (Generic a, HasDatatypeInfo a) => Proxy (name :: Symbol) -> a -> b
to project a field from an arbitrary record using a type-level st...
Bourges asked 7/4, 2021 at 18:41
2
Context
If we have
data Foo = Foo { x :: Maybe Int, y :: Maybe Text }
we can already build it up applicative-style in an Applicative context (here IO) as
myfoo :: IO Foo
myfoo = Foo <$> ...
Obstreperous asked 24/10, 2016 at 8:52
1
Solved
In Sum of Products approach, how would one retrieve the record function? An example code below with record datatype (ghc 7.10.3):
{-# LANGUAGE DeriveGeneric #-}
import qualified GHC.Generics as GH...
Lotz asked 28/3, 2016 at 0:42
1
For another answer of mine, I wrote the following code, providing diagonally traversed Universe instances for enumerable Generics (it's slightly updated from the version there, but uses the same lo...
Rwanda asked 8/5, 2014 at 16:22
1
I have a class that provides a globally unique identifier for types:
class Named a where
nameOf :: a -> (String,String,String) -- (Package, Module, Identifier)
default nameOf :: (Generic a, N...
Fatma asked 26/1, 2015 at 21:27
1
Are any tasks that are possible only with SYB, or are much easier with it, when compared to GHC Generics?
Adaiha asked 12/11, 2014 at 18:5
2
Solved
I'm trying to learn GHC Generics. After reviewing several examples, I wanted to try to create a generic Functor instances (disregarding that GHC can derive them automatically for me). However, I re...
Crispy asked 19/7, 2013 at 16:17
1
© 2022 - 2024 — McMap. All rights reserved.