Menu
  • HOME
  • TAGS

How can I automatically derive Typeable instance for DataKinds derived types?

haskell,types,deriving,data-kinds

Yes, you can use the AutoDeriveTypeable extension. For the other part, the closest thing I could think of was to put Typeable c => inside the GADT definition as follows: {-# LANGUAGE AutoDeriveTypeable #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE DataKinds #-} import Data.Typeable import qualified Data.Map as M type...

How to use deriving and batteries at same time in OCaml?

ocaml,deriving,ocaml-batteries

I've had no problem installing both libraries (batteries 2.1.0 and deriving 0.5) with OCaml 4.00.1 (and Opam 0.9.6) You might want to check this question: opam upgrade wants to downgrade a bunch of packages -- not sure whether this is relevant, but it seems that it might be. Good...

Are all differentiable types Monads

haskell,monads,zipper,deriving

No. The void functor data V a is differentiable, but return cannot be implemented for it.

Why does Either derives Show but Maybe does not?

haskell,show,maybe,either,deriving

The instance for Maybe is defined explicitly in GHC.Show, along with instances for a whole bunch of other common types like tuples. You can find out where an instance was defined using the :i command in ghci: Prelude> :i Maybe data Maybe a = Nothing | Just a -- Defined...

Opam install deriving, syntax error

ocaml,deriving,opam

It seems you forgot to provide deriving.syntax package. Use the following _tags file: true: syntax(camlp4o) true: package(deriving,deriving.syntax) true: thread,debug,annot true: bin_annot ...

Custom deriving(Read,Show) for enum type

haskell,template-haskell,deriving

The paper Invertible Syntax Descriptions: Unifying Parsing and Pretty Printing describes one particularly idiomatic solution. Your example looks like this, using the invertible-syntax package based on that paper: import Prelude hiding (Applicative(..), print) import Data.Maybe (fromJust) import Text.Syntax import Text.Syntax.Parser.Naive import Text.Syntax.Printer.Naive data TVShow = BobsBurgers | MrRobot | BatmanTAS...

Deriving instance Typeable with context

haskell,deriving

Might I suggest not doing that. Datatype contexts are bad in pretty much every way possible. There's a reason that they've been deprecated. If you really, really, want them, use GADTs. If you don't use contexts, this is trivial {-# LANGUAGE DeriveDataTypeable #-} import Data.Typeable import Data.Data data ErrorResponse ty...

Deriving Generic from data declared in another file fails

haskell,ghc,deriving,ghc-generics

I'm using GHC 7.8.3 (from the Haskell Platform). Below is a cabal.config file with the specific versions used in the sandbox. constraints: aeson ==0.8.0.2, array ==0.5.0.0, attoparsec ==0.12.1.2, base ==4.7.0.1, bytestring ==0.10.4.0, containers ==0.5.5.1, deepseq ==1.3.0.2, dlist ==0.7.1, generic ==0.1.0.0, generic-aeson ==0.2.0.2, generic-deriving ==1.7.0, ghc-prim ==0.3.1.0, hashable ==1.2.2.0, integer-gmp ==0.5.1.0,...