私は過去数か月間 Haskell を学んでおり、Haskell + Persistent に関するこのチュートリアルに従ってみようとしています。
https://www.yesodweb.com/book/persistent#persistent_code_generation
module Main where
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
import Database.Persist
import Database.Persist.TH
import Database.Persist.Sqlite
import Control.Monad.IO.Class (liftIO)
mkPersist sqlSettings [persistLowerCase|
Person
name String
age Int
deriving Show
|]
私は以前にこの構文に出くわしたことはありません(チュートリアルで「QuasiQuotes」について話しているので、それが何であるかを推測しています)が、チュートリアルからコードを直接取得したので、コンパイルする必要があると思います. ただし、そうではなく、次のエラーが表示されます。
/home/will/programming/learn-haskell/postgres-example/app/Main.hs:15:1: error:
parse error (possibly incorrect indentation or mismatched brackets)
|
15 | Person
| ^
-- While building package postgres-example-0.1.0.0 using:
/home/will/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.4 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0 build exe:simple --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
私の cabal ファイル内の構成は次のとおりです。
name: postgres-example
version: 0.1.0.0
synopsis: An example of using Haskell and PostGres with persistent
description: Please see README.md
license: BSD3
license-file: LICENSE
author: Will Taylor
copyright: 2020, Will Taylor
category: Web
build-type: Simple
cabal-version: >=1.10
executable simple
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base
, persistent
, persistent-template
, persistent-postgresql
, monad-logger
default-language: Haskell2010
誰かが私を助けることができれば、それは素晴らしいことです.