sebastiaanvisser / fclabels Goto Github PK
View Code? Open in Web Editor NEWFirst class composable record labels for Haskell.
License: Other
First class composable record labels for Haskell.
License: Other
Resolving dependencies...
Configuring fclabels-2.0.2.2...
Building fclabels-2.0.2.2...
Preprocessing library fclabels-2.0.2.2...
[ 1 of 10] Compiling Data.Label.Point ( src/Data/Label/Point.hs, dist/build/Data/Label/Point.o )
[ 2 of 10] Compiling Data.Label.Poly ( src/Data/Label/Poly.hs, dist/build/Data/Label/Poly.o )
[ 3 of 10] Compiling Data.Label.Mono ( src/Data/Label/Mono.hs, dist/build/Data/Label/Mono.o )
[ 4 of 10] Compiling Data.Label.Derive ( src/Data/Label/Derive.hs, dist/build/Data/Label/Derive.o )
src/Data/Label/Derive.hs:379:25:
Template Haskell bracket illegal in a stage-1 compiler
[| failArrow |]
src/Data/Label/Derive.hs:380:25:
Template Haskell bracket illegal in a stage-1 compiler
[| zeroArrow |]
Is this expected? I installed Haskell through the haskell-platform package.
This program throws compiler errors:
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
import Prelude hiding ((.), id)
import Data.Label
data D = A { _a :: () } | B { _b :: Char }
$(mkLabels [''D])
Without line 1 {-# LANGUAGE GADTs #-}
there is no problem. What's going on?
GHC 8.0 RC2 ships with template-haskell-2.11.0.0. You have the constraint template-haskell >= 2.2 && < 2.11. Needs loosening to allow installing.
I note you have tested-with GHC==8.0.1, so this might be a late-in-the-day bounds bump from template-haskell.
In GHCi with fclabels-1.1.0.1 loaded (along with 'id' from Control.Category loaded):
*Main> get id $ set id 1 2
2
which violates the law
get l (set l a f) == a
Which has a base higher than you support
Can be seen here: https://travis-ci.org/sebastiaanvisser/fclabels/builds/103617479
Preprocessing library fclabels-2.0.2.3...
[10 of 10] Compiling Data.Label.Base ( src\Data\Label\Base.hs, dist\build\Data\Label\Base.o )
Segmentation fault/access violation in generated code
cabal: Error: some packages failed to install:
fclabels-2.0.2.3 failed during the building phase. The exception was:
ExitFailure 1
Hey,
I have a lens such that (C.Definition -> C.Definition) :~> ([C.BlockItem] -> [C.BlockItem])
.
And a lens such that (C.BlockItem -> C.BlockItem) :~> ([C.Init] -> [C.Init])
I want to be able to compose them more intuitively.
Here is what I have for when I want to work with them:
fu1 :: Monad m => (BlockItem -> m a) -> m [a]
fu1 f = maybe (return []) (mapM f) $ P.get fundef ctes
fu2 :: Monad m => (Init -> m a) -> m [[a]]
fu2 f = fu1 ((\x -> maybe (return []) (mapM f) $ P.get blockdef x))
fu3 :: Monad m => (Initializer -> m ()) -> m [[()]]
fu3 f = fu2 (\y -> maybe (return ()) f $ P.get initdef y)
So calling fu3 print
will print the initdef
s inside of blockdef
s inside of fundef
s, but it is a bit clunky to write it this way.
Do you have any tips on how you would of composed them?
Full source code here: https://gist.github.com/maxpow4h/6944603
Thanks,
The 1.1.2 release on hackage did not pull in the changes from github it appears!
[ 8 of 10] Compiling Data.Label.Base ( src/Data/Label/Base.hs, dist/build/Data/Label/Base.dyn_o )
src/Data/Label/Base.hs:79:10: error:
• Couldn't match expected type ‘Poly.Lens
cat (Maybe a -> Maybe b) (a -> b)’
with actual type ‘Unit
(Poly.Lens cat0 (Maybe a0 -> Maybe b0) (a0 -> b0))’
• In the expression:
(Unit (point
$ (Data.Label.Point.Point
((Control.Arrow.zeroArrow Control.Arrow.||| Control.Category.id)
Control.Category.<<<
arr
(\ f
-> case f of
Just a -> Right a
_ -> Left ())))
((Data.Label.Derive.modifier
((Control.Arrow.zeroArrow Control.Arrow.||| Control.Category.id)
Control.Category.<<<
arr
(\ f
-> case f of
Just a -> Right a
_ -> Left ())))
((Control.Arrow.zeroArrow Control.Arrow.||| Control.Category.id)
Control.Category.<<<
arr
(\ (v, f)
-> case f of
Just _ -> Right (Just v)
_ -> Left ())))) ::
forall cat a b.
(ArrowChoice cat, ArrowApply cat, ArrowZero cat) =>
Unit Poly.Lens cat (Maybe a -> Maybe b) (a -> b))
In an equation for ‘just’:
just
= (Unit (point
$ (Data.Label.Point.Point
((Control.Arrow.zeroArrow Control.Arrow.||| Control.Category.id)
Control.Category.<<<
arr
(\ f
-> case f of
Just a -> Right a
_ -> Left ())))
((Data.Label.Derive.modifier
((Control.Arrow.zeroArrow Control.Arrow.||| Control.Category.id)
Control.Category.<<<
arr
(\ f
-> case f of
Just a -> Right a
_ -> Left ())))
((Control.Arrow.zeroArrow Control.Arrow.||| Control.Category.id)
Control.Category.<<<
arr
(\ (v, f)
-> case f of
Just _ -> Right (Just v)
_ -> Left ())))) ::
forall cat a b.
(ArrowChoice cat, ArrowApply cat, ArrowZero cat) =>
Unit Poly.Lens cat (Maybe a -> Maybe b) (a -> b))
• Relevant bindings include
just :: Poly.Lens cat (Maybe a -> Maybe b) (a -> b)
(bound at src/Data/Label/Base.hs:79:1)
|
79 | just = $(getLabel ''Maybe)
| ^^^^^^^^^^^^^^^^
Hi @sebastiaanvisser,
The module Control.Monad.Trans.Error
was deprecated a long time ago and finally removed in transformers
0.6 which is shipped with GHC 9.6.
This leads to this error:
[1 of 1] Compiling Main ( test/TestSuite.hs, dist/build/suite/suite-tmp/Main.dyn_o )
test/TestSuite.hs:26:1: error:
Could not find module ‘Control.Monad.Trans.Error’
Perhaps you meant
Control.Monad.Trans.Writer (from transformers-0.6.1.0)
Control.Monad.Trans.RWS (from transformers-0.6.1.0)
Control.Monad.Trans.Cont (from transformers-0.6.1.0)
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
26 | import Control.Monad.Trans.Error (Error (noMsg))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Removing the offending line, another error occurs:
[1 of 1] Compiling Main ( test/TestSuite.hs, dist/build/suite/suite-tmp/Main.dyn_o )
test/TestSuite.hs:187:8: error: [GHC-39999]
• No instance for ‘MonadPlus (Either String)’
arising from a use of ‘mA’
• In the expression: mA
In an equation for ‘mA_f’: mA_f = mA
|
187 | mA_f = mA
| ^^
In the relevant file, test/TestSuite.hs, there is the following remark:
-- These instance are needed for the `Failing.Lens String` instance,
-- since that needs a `MonadZero` constraint on `Kleisli (Either String)`,
-- which in turn needs a `MonadPlus (Either String)` constraint.
-- These instances used to exist in transformers but were removed in
-- 0.5.0.0 accidentally, and added in 0.5.2.0. We can probably remove
-- this ifdef after GHC 8 rc3 is released, which will include
-- transformers-0.5.2.0.
#if MIN_VERSION_transformers(0,5,0) && !MIN_VERSION_transformers(0,5,2) && MIN_VERSION_base(4,9,0)
instance (Error e) => Alternative (Either e) where
empty = Left noMsg
Left _ <|> n = n
m <|> _ = m
instance Error e => MonadPlus (Either e) where
mzero = Left noMsg
Left _ `mplus` n = n
m `mplus` _ = m
#endif
Not quite sure what to make of it. Do you have an idea how to fix this issue?
-- Vekhir
The latest version of fclabels fails in the Haddock stage:
Setup: dist/doc/html/fclabels/haddock-prolog3783.txt: invalid argument
This probably happens because the description stanza in the Cabal contains something that's not a valid Unicode/UTF-8 character. A complete build log is available at http://hydra.cryp.to:8080/build/6514/nixlog/2/raw.
newtype Point m f i o = Point { runPoint :: f -> m (i -> m f, o) }
getSetPoint :: Monad m => (f -> m o) -> (i -> f -> m f) -> Point m f i o
getSetPoint g s = Point $ \f -> do
o <- g f
return (\i -> s i f, o)
_get :: Monad m => Point m f i o -> f -> m o
_get (Point p) = liftM snd . p
_set :: Monad m => Point m f i o -> i -> f -> m f
_set (Point p) i f = do (s, _) <- p f; s i
_modify :: Monad m => Point m f i o -> (o -> m i) -> f -> m f
_modify (Point p) m f = do (s, o) <- p f; (s <=< m) o
instance Monad m => Functor (Point m f i) where
fmap f (Point p) = Point $ liftM (fmap f) . p
instance Monad m => Applicative (Point m f i) where
pure a = Point $ \f -> return (const (return f), a)
Point pf <*> Point pa = Point $ \f -> do
(fs, fo) <- pf f
(_ , ao) <- pa f
return (\i -> do f' <- fs i; (as, _) <- pa f'; as i, fo ao)
bimap :: Monad m => (o' -> m o) -> (i -> m i') -> Point m f i' o' -> Point m f i o
bimap g h p = Point . runKleisli $ (arr (<=< h) *** Kleisli g) . Kleisli (runPoint p)
I just downloaded GHC 7.6 RC1 and tried to build the newest Hackage version of fclabels. This does not work. The error is
Resolving dependencies...
Configuring fclabels-1.1.4...
Building fclabels-1.1.4...
Preprocessing library fclabels-1.1.4...
[1 of 7] Compiling Data.Label.Abstract ( src/Data/Label/Abstract.hs, dist/build/Data/Label/Abstract.o )
src/Data/Label/Abstract.hs:27:12:
Unexpected type `~>' where type variable expected
In the declaration of `Point ~> f i o'
cabal: Error: some packages failed to install:
fclabels-1.1.4 failed during the building phase. The exception was:
Sorry, for not attaching a patch and thanks for your help :-)
In the paragraph below the applicative example.
@bergmark
When building fclabels
2.0.5.1 using GHC 9.8 on Arch, the following error occurs:
[ 6 of 10] Compiling Data.Label.Derive ( src/Data/Label/Derive.hs, dist/build/Data/Label/Derive.dyn_o )
src/Data/Label/Derive.hs:310:55: error: [GHC-83865]
• Couldn't match type ‘BndrVis’ with ‘()’
Expected: [TyVarBndr ()]
Actual: [TyVarBndr BndrVis]
• In the fourth argument of ‘generateLabel’, namely ‘vars’
In the second argument of ‘($)’, namely
‘generateLabel failing concrete name vars cons’
In a stmt of a 'do' block:
forM fields $ generateLabel failing concrete name vars cons
|
310 | forM fields $ generateLabel failing concrete name vars cons
| ^^^^
This issue looks similar to linear-generics/linear-generics#25
The offending line is src/Data/Label/Derive.hs#L310
What do you think?
-- Vekhir
Offending bounds:
base >=4.5 && <4.17,
base-orphans >=0.8.2 && <0.9,
template-haskell >=2.2 && <2.19
Confirmed that
base-4.17.2.0
,base-orphans-0.9.0
, andtemplate-haskell-2.19.0
work.
When I try to build fclabels-2.0.3.3 under ghc-8.6.3 and cabal-2.4.1.0, ghc never finishes compiling Data.Label.Base. (Task manager shows it happily keeps working overnight, until killed.) (This is on Windows 10.)
No problem building fclabels-2.0.3.3 using ghc-8.4.4 and stack resolver lts-12.20. This r/haskell reddit comment [1] indicates that ghc-8.6.2 and earlier versions successfully built fclabels-2.0.3.3 on Windows 10 also, and only had trouble when using ghc-8.6.3.
My use case is the same as in the reddit comment: I'm trying to build HIE on Windows 10. The 8.6.3 target for HIE uses stack resolver lts-13.0, but as I found the problem is the same when trying to build fclabels without stack, using cabal.
I'll stick with building using an earlier ghc but thought I should note the problem.
[1] https://www.reddit.com/r/haskell/comments/a1u9qj/monthly_hask_anything_december_2018/ech9ael
[2] fclabels_build_cabal_output.txt
Which has base library 4.12, but fclabels demands < 4.12.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.