Skip to content

Instantly share code, notes, and snippets.

I installed stack 1.9.3 x86_64 hpack-0.31.2
I tried to test it out like this but it failed:
542be632325c:/# stack new funny new-template -p "author-name:blah" -p "category:blah" -p "copyright:blah" -p "github-username:blah" -p "author-email:blah@blah.com"
Downloading template "new-template" to create project "funny" in funny/ ...
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- funny/
RUN git clone --branch ghc-8.4 https://github.com/ghcjs/ghcjs.git
WORKDIR ghcjs
RUN git submodule update --init --recursive
RUN ./utils/makePackages.sh
RUN ./utils/makeSandbox.sh
RUN cabal install
ENV PATH /ghcjs/.cabal-sandbox/bin:$PATH
WORKDIR /
RUN ghcjs-boot -v2
RUN /ghcjs/utils/makePackages.sh
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for twi-0.1.0.0:
template-haskell-2.11.1.0 from stack configuration does not match >=2.14.0.0 (latest
matching version is 2.14.0.0)
needed since twi is a build target.
Some different approaches to resolving this:
* Set 'allow-newer: true'
NOTE: the types used below, e.g. Name or UnQual come from Language.Haskell.Exts
I am using generic-lens to do this kind of traversal:
putStrLn $ show $ toListOf (types @(Name SrcSpanInfo)) foo
When foo is this expression it works fine:
(UnQual (SrcSpanInfo {srcInfoSpan = SrcSpan "Syntax.hs" 268 24 268 32, srcInfoPoints = []})
This code:
toListOf (types @(Name SrcSpanInfo))
$ (TyCon
(SrcSpanInfo
{srcInfoSpan = SrcSpan "Foo.hs" 268 24 268 32,
srcInfoPoints = []})
(UnQual
(SrcSpanInfo
{srcInfoSpan = SrcSpan "Foo.hs" 268 24 268 32,
data Module l
= Module l (Maybe (ModuleHead l)) [ModulePragma l] [ImportDecl l] [Decl l]
-- ^ an ordinary Haskell module
| XmlPage l (ModuleName l) [ModulePragma l] (XName l) [XAttr l] (Maybe (Exp l)) [Exp l]
-- ^ a module consisting of a single XML document. The ModuleName never appears in the source
-- but is needed for semantic purposes, it will be the same as the file name.
| XmlHybrid l (Maybe (ModuleHead l)) [ModulePragma l] [ImportDecl l] [Decl l]
(XName l) [XAttr l] (Maybe (Exp l)) [Exp l]
-- ^ a hybrid module combining an XML document with an ordinary module
deriving (Eq,Ord,Show,Typeable,Data,Foldable,Traversable,Functor,Generic)
I am using generic lens to access this algebraic data type's elements by position. It works for position 1 and fails for position 2.
putStrLn $ show $ ast ^. position @1
putStrLn $ show $ ast ^. position @2
Here's the algebraic data type:
data Module l
= Module l (Maybe (ModuleHead l)) [ModulePragma l] [ImportDecl l] [Decl l]
public static String pingPongBallToStringThatIsBothMachineReadableAndHumanReadable(PingPongBall a){
Function<PingPongBall,byte[]> funky = x -> x.toByteArray();
return funky
.andThen(x->Base64.getEncoder().encode(x))
.andThen(x->x+"\n"+a)
.apply(a);
}
@fragamus
fragamus / gist:69bb9a5816f952c98f456f719b03deb7
Created January 30, 2019 23:41
partially applied constructor... need help grokking this code
data Store s a = Schmore (s -> a) s deriving Functor
instance Comonad (Store s) where
extract (Schmore f s) = f s
duplicate (Schmore f s) = Schmore (Schmore f) s
data Store s a = Store (s -> a) s deriving Functor
instance Comonad (Store s) where
extract (Store f s) = f s
duplicate (Store f s) = Store (Store f) s